-
-
Save coresh/47e6c6d60c59467eb87d7e309f987c7c to your computer and use it in GitHub Desktop.
Revisions
-
farinspace revised this gist
Jan 9, 2017 . 1 changed file with 18 additions and 25 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,32 +1,25 @@ <?php function combos($data, &$all = array(), $group = array(), $val = null, $i = 0) { if (isset($val)) { array_push($group, $val); } if ($i >= count($data)) { array_push($all, $group); } else { foreach ($data[$i] as $v) { combos($data, $all, $group, $v, $i + 1); } } return $all; } $data = array( array('a', 'b'), array('e', 'f', 'g'), array('w', 'x', 'y', 'z'), ); $combos = combos($data); echo '<pre>'; print_r($combos); echo '</pre>'; -
Dimas Begunoff revised this gist
Aug 5, 2011 . No changes.There are no files selected for viewing
-
Dimas Begunoff renamed this gist
Aug 5, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Dimas Begunoff revised this gist
Aug 5, 2011 . 1 changed file with 170 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,170 @@ Array ( [0] => Array ( [0] => a [1] => e [2] => w ) [1] => Array ( [0] => a [1] => e [2] => x ) [2] => Array ( [0] => a [1] => e [2] => y ) [3] => Array ( [0] => a [1] => e [2] => z ) [4] => Array ( [0] => a [1] => f [2] => w ) [5] => Array ( [0] => a [1] => f [2] => x ) [6] => Array ( [0] => a [1] => f [2] => y ) [7] => Array ( [0] => a [1] => f [2] => z ) [8] => Array ( [0] => a [1] => g [2] => w ) [9] => Array ( [0] => a [1] => g [2] => x ) [10] => Array ( [0] => a [1] => g [2] => y ) [11] => Array ( [0] => a [1] => g [2] => z ) [12] => Array ( [0] => b [1] => e [2] => w ) [13] => Array ( [0] => b [1] => e [2] => x ) [14] => Array ( [0] => b [1] => e [2] => y ) [15] => Array ( [0] => b [1] => e [2] => z ) [16] => Array ( [0] => b [1] => f [2] => w ) [17] => Array ( [0] => b [1] => f [2] => x ) [18] => Array ( [0] => b [1] => f [2] => y ) [19] => Array ( [0] => b [1] => f [2] => z ) [20] => Array ( [0] => b [1] => g [2] => w ) [21] => Array ( [0] => b [1] => g [2] => x ) [22] => Array ( [0] => b [1] => g [2] => y ) [23] => Array ( [0] => b [1] => g [2] => z ) ) -
Dimas Begunoff revised this gist
Aug 5, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ function combos($data, $all = array(), $group = array(), $val = null, $i = 0) $data = array ( array('a', 'b'), array('e', 'f', 'g'), array('w', 'x', 'y', 'z'), ); -
Dimas Begunoff revised this gist
Aug 4, 2011 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,3 @@ function combos($data, $all = array(), $group = array(), $val = null, $i = 0) { if (isset($val)) @@ -27,6 +20,13 @@ function combos($data, $all = array(), $group = array(), $val = null, $i = 0) return $all; } $data = array ( array('a', 'b'), array('a', 'b', 'c'), array('w', 'x', 'y', 'z'), ); $combos = combos($data); print_r($combos); -
Dimas Begunoff renamed this gist
Aug 4, 2011 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Dimas Begunoff revised this gist
Aug 4, 2011 . 1 changed file with 1 addition and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,6 +29,4 @@ function combos($data, $all = array(), $group = array(), $val = null, $i = 0) $combos = combos($data); print_r($combos); -
Dimas Begunoff created this gist
Aug 4, 2011 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,34 @@ $data = array ( array('a', 'b'), array('a', 'b', 'c'), array('w', 'x', 'y', 'z'), ); function combos($data, $all = array(), $group = array(), $val = null, $i = 0) { if (isset($val)) { array_push($group, $val); } if ($i >= count($data)) { array_push($all, $group); } else { foreach ($data[$i] as $v) { combos($data, &$all, $group, $v, $i + 1); } } return $all; } $combos = combos($data); print_r($combos); exit;