3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function array_by_path($value, $path) { if (empty($path)) { return $value; } $curr = array_shift($path); if (!isset($value[$curr])) { return null; } elseif (is_array($value[$curr])) { return array_by_path($value[$curr]); } return $value; } $test = array( 'wot' => array( 'mate' => 'hello' ) ); echo array_by_path($test, ['wot', 'mate']);
based on g6A5r
Output for 7.1.0 - 7.2.0
Fatal error: Uncaught ArgumentCountError: Too few arguments to function array_by_path(), 1 passed in /in/7jfNq on line 9 and exactly 2 expected in /in/7jfNq:3 Stack trace: #0 /in/7jfNq(9): array_by_path(Array) #1 /in/7jfNq(20): array_by_path(Array, Array) #2 {main} thrown in /in/7jfNq on line 3
Process exited with code 255.
Output for 5.4.0 - 7.0.20
Warning: Missing argument 2 for array_by_path(), called in /in/7jfNq on line 9 and defined in /in/7jfNq on line 3 Notice: Array to string conversion in /in/7jfNq on line 20 Array
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/7jfNq on line 20
Process exited with code 255.