3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $selector = 'foo[bar][foo]'; $input = array('foo' => array('bar' => array('tar' => 'qux'))); $value = $input; $path = explode('[', str_replace(']', '', $selector)); foreach ($path as $name) { if (array_key_exists($name, $value)) { $value = $value[$name]; } else { $value = null; break; } } var_dump($value);
Output for 4.3.0 - 7.1.0
NULL