3v4l.org

run code in 300+ PHP versions simultaneously
<?php function traverseArray(array $a, array $keys) { $tmp = $a; foreach ($keys as $key) { if (!isset($tmp[$key])) { return null; } $tmp = $tmp[$key]; } return $tmp; } var_dump(traverseArray(array('a' => array('b' => array('c' => array('d' => 5)))), array('a', 'b', 'c', 'd')));
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.30, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.27, 8.0.0 - 8.0.15, 8.1.0 - 8.1.2
int(5)

preferences:
54.13 ms | 462 KiB | 5 Q