3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $option_array[] = [ 'Condition' => [ 'nm' => 'Near Mint/Mint', 'sp' => 'Slightly Played', 'hp' => 'Heavily PLayed' ], 'Style' => [ 'normal' => 'Normal', 'foil' => 'Foil' ] ]; $N = 1; foreach ($option_array as $options) $N *= count($options); $all_combinations = array(); for( $i = 0 ; $i < $N ; ++$i ) { $all_combinations[$i] = array(); $q = $i; for( $j = count($option_array)-1 ; 0 <= $j ; --$j ) { $opt = $option_array[$j]; $nopts = count($opt['options']); $all_combinations[$i][$opt['name']] = $opt['options'][$q % $nopts]; $q = floor($q / $nopts); } } print_r( $all_combinations );
Output for 7.0.0 - 7.1.0
Notice: Undefined index: options in /in/subUv on line 26 Notice: Undefined index: name in /in/subUv on line 27 Fatal error: Uncaught DivisionByZeroError: Modulo by zero in /in/subUv:27 Stack trace: #0 {main} thrown in /in/subUv on line 27
Process exited with code 255.
Output for 5.4.0 - 5.6.28, hhvm-3.12.0
Notice: Undefined index: options in /in/subUv on line 26 Notice: Undefined index: name in /in/subUv on line 27 Warning: Division by zero in /in/subUv on line 27 Notice: Undefined index: options in /in/subUv on line 27 Warning: Division by zero in /in/subUv on line 28 Notice: Undefined index: options in /in/subUv on line 26 Notice: Undefined index: name in /in/subUv on line 27 Warning: Division by zero in /in/subUv on line 27 Notice: Undefined index: options in /in/subUv on line 27 Warning: Division by zero in /in/subUv on line 28 Array ( [0] => Array ( [] => ) [1] => Array ( [] => ) )
Output for hhvm-3.10.0

Process exited with code 153.
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/subUv on line 2
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/subUv on line 2
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/subUv on line 2
Process exited with code 255.