3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function transformQuestionnaire($arr) { $new_arr = array(); foreach ($arr as $nr => $array){ if (!in_array($array[0], $new_arr)){ //not a double $new_arr[$array[0]] = $array[1]; } else { //Append it to the existing value $new_arr[$array[0]] = $new_arr[$array[0]] . '|' . $array[1]; } } return $new_arr; } $input = array( 1 => array("one", "potato"), 2 => array("two", "fries"), 3 => array("one", "ketchup"), ); print(var_dump(transformQuestionnaire($input)); ?>
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.4.29
Parse error: syntax error, unexpected ';' in /in/eFEpr on line 20
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/eFEpr on line 20
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/eFEpr on line 20
Process exited with code 255.