3v4l.org

run code in 300+ PHP versions simultaneously
<?php $tree = [ 10 => [], 11 => [ 4 => [], 5 => [], 6 => [] ] ]; $path = array(11,5,0); $inseration = array('A','B'); $current = &$tree; foreach($path as $key){ $current = &$current[$key]; } $current = $inseration; print_r($tree);

preferences:
23.6 ms | 404 KiB | 5 Q