3v4l.org

run code in 300+ PHP versions simultaneously
<?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']);

preferences:
44.59 ms | 402 KiB | 5 Q