3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr = array( array('optional' => 0, 2, 9), array('optional' => 0, 3, 4),/* array('optional' => 0, 6, 7, 8),*/ array('optional' => 1, 6,),/* array('optional' => 1, 6, 7, 8, 5, 9), array('optional' => 1, 6, 7, 8, 10, 11, 12)*/ ); function generateCombinations(array $array) { foreach (array_pop($array) as $value) { $option = $value["optional"]; if (count($array)) { foreach (generateCombinations($array) as $combination) { yield array_merge([$value], $combination); }; } else { yield [$value]; if($option == 1) yield []; } } } foreach(generateCombinations($arr) as $combination){ echo implode(",", $combiantion) . "\n"; }
Output for git.master, git.master_jit
Warning: Trying to access array offset on value of type int in /in/gNBsJ on line 15 Warning: Trying to access array offset on value of type int in /in/gNBsJ on line 15 Warning: Trying to access array offset on value of type int in /in/gNBsJ on line 15 Warning: Undefined variable $combiantion in /in/gNBsJ on line 30 Fatal error: Uncaught TypeError: implode(): Argument #1 ($pieces) must be of type array, string given in /in/gNBsJ:30 Stack trace: #0 /in/gNBsJ(30): implode(',', NULL) #1 {main} thrown in /in/gNBsJ on line 30
Process exited with code 255.
Output for rfc.property-hooks
Warning: Trying to access array offset on int in /in/gNBsJ on line 15 Warning: Trying to access array offset on int in /in/gNBsJ on line 15 Warning: Trying to access array offset on int in /in/gNBsJ on line 15 Warning: Undefined variable $combiantion in /in/gNBsJ on line 30 Fatal error: Uncaught TypeError: implode(): Argument #1 ($pieces) must be of type array, string given in /in/gNBsJ:30 Stack trace: #0 /in/gNBsJ(30): implode(',', NULL) #1 {main} thrown in /in/gNBsJ on line 30
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
166.41 ms | 408 KiB | 5 Q