3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getValue($testArray, $exploded, $index) { if(is_array($testArray[$exploded[$index]])) { return getValue($testArray[$exploded[$index]], $exploded, ++$index); } else { return $testArray[$exploded[$index]]; } } $string = 'router.format'; $testArray = array( 'router' => array( 'format' => 'xml', ), ); $exploded = explode(".", $string); /*if(count($exploded) != count($testArray)) { throw new Exception("mismatch"); }*/ $desiredValue = getValue($testArray, $exploded, 0); print_r($desiredValue);
based on 1Jm14
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
xml