3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = array(array(1, 2), array(3, 4), array(5)); function get_combinations($arrays) { $result = array(array()); $count = count($arrays); $first_array = $arrays[0]; if($count > 2) { $array_merg = get_combinations(array_slice($arrays, 1)); } else { $array_merg = $arrays[1]; } $tmp = array(); foreach($first_array as $arele1) { //print_r($arele1); foreach($array_merg as $arele2) { print_r($arele2); if(is_array($arele2)) { echo 'asds' $tmp[] = array_unshift($arele2,$arele1); } else { $tmp[] = array($arele1,$arele2); } print_r($tmp); } } print_r($tmp); return $tmp; } var_dump(get_combinations($a));
Output for 5.4.0 - 5.4.28
Parse error: syntax error, unexpected '$tmp' (T_VARIABLE), expecting ',' or ';' in /in/lTNYl on line 22
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_VARIABLE, expecting ',' or ';' in /in/lTNYl on line 22
Process exited with code 255.

preferences:
179.26 ms | 1395 KiB | 65 Q