3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $somearray = array( 'item1' => array( 'subitem1' => 'Some value', 'subitem2' => 'Some other value', 'subitem3' => array( 'subsubitem' => 'A sub value' ) ), 'item2' => 'a different value' ); $map = "item1/subitem3/subsubitem"; $parts = explode("/", $map); $currentData = $somearray; for ($i = 0; $i < count($parts); $i++) { $currentData = $currentData[$parts[$i]]; } $result = $currentData; echo $result;
Output for 4.3.0 - 7.1.0
A sub value