PHP code example of fabis94 / php-twiddle

1. Go to this page and download the library: Download fabis94/php-twiddle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fabis94 / php-twiddle example snippets


$setSize = 10;
$combinationSize = 2;
$twiddle = new Twiddle($setSize, $combinationSize);

// Get all possible combinations
$values = [1,2,3,4,5,6,7,8,9,0]
$allCombinations = $twiddle->getAllCombinations($values);

// Get first three combinations
$values = ['a','b','c','d','e','f','g','h','j','k']
$combinationGenerator = $twiddle->getCombinationGenerator($values);
$firstThree = [];
$i = 0;
foreach ($combinationGenerator as $combination) {
    if ($i >= 3) break;
    
    $firstThree[] = $combination;
    $i++;
}