3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = [ "one" => "one", "two" => "two", "group1" => [ "three" => "three", "four" => "four", "group2" => [ "five" => "five", ], ], "group3" => [ "six" => "six", ] ]; function mergeRecursive(array $array, $result = []) { foreach($array as $k => $v) { if(!is_array($array)) $result[] = $v; else $result[] = $k . mergeRecursive($v); } return $result; } $result = mergeRecursive($array); print_r($result);
Output for 7.0.0 - 7.2.0
Notice: Undefined variable: array in /in/ZW9IO on line 35 Fatal error: Uncaught TypeError: Argument 1 passed to mergeRecursive() must be of the type array, null given, called in /in/ZW9IO on line 35 and defined in /in/ZW9IO:22 Stack trace: #0 /in/ZW9IO(35): mergeRecursive(NULL) #1 {main} thrown in /in/ZW9IO on line 22
Process exited with code 255.
Output for 5.4.0 - 5.6.28
Notice: Undefined variable: array in /in/ZW9IO on line 35 Catchable fatal error: Argument 1 passed to mergeRecursive() must be of the type array, null given, called in /in/ZW9IO on line 35 and defined in /in/ZW9IO on line 22
Process exited with code 255.
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/ZW9IO on line 3
Process exited with code 255.