3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $stuff = ['a' => ['b' => 'c']]; $path = 'a.b'; $parts = explode('.', $path); $value = &$stuff; foreach ($parts as $part) { if (isset($value[$part])) { $value = &$value[$part]; } else { throw new \RuntimeException('fail at: ' . $part); } } var_dump($stuff); var_dump($value);
based on 8C4J2
Output for 5.4.9 - 7.3.0rc4
array(1) { ["a"]=> array(1) { ["b"]=> &string(1) "c" } } string(1) "c"
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/fngtn on line 3
Process exited with code 255.