3v4l.org

run code in 300+ PHP versions simultaneously
<?php function permute($base, $add) { $result = []; if (count($base) > 0) { foreach ($base as $val1) { if (count($add) > 0) { foreach ($add as $val2) { $result[] = array_merge($val1, $val2); } } else { $result = $base; } } } else { $result = $add; } return $result; } function getPermutations(array $optionSet) { $stuff = []; $permutations = []; $index = 0; foreach ($optionSet as $key => $set) { $stuff[$index] = []; foreach ($set as $code => $name) { array_push($stuff[$index], [$key => $code]); } $index++; } $count = count($stuff); for ($i = 0; $i < $count; $i++) { $temp = array_map( [ $this, "permute", ], [$permutations], [$stuff[$i]] ); $permutations = $temp[0]; } return $permutations; } $options = [ 'Condition' => [ 'nm' => 'Near Mint/Mint', 'sp' => 'Slightly Played', 'hp' => 'Heavily Played' ], 'Style' => [ 'normal' => 'Normal', 'foil' => 'Foil' ] ]; var_dump(getPermutations($options));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught Error: Using $this when not in object context in /in/kiqj2:40 Stack trace: #0 /in/kiqj2(67): getPermutations(Array) #1 {main} thrown in /in/kiqj2 on line 40
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:
52.45 ms | 401 KiB | 8 Q