3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array = array('a', 'b', 'c'); function nestArray($arr) { if(empty($arr)) { return array(); } return array(array_shift($arr) => nestArray($arr)); } var_dump(nestArray($array));
based on MsBcJ
Output for 4.3.0 - 7.1.0
array(1) { ["a"]=> array(1) { ["b"]=> array(1) { ["c"]=> array(0) { } } } }