<?php $a = ["I", "need", "this", "to", "be", "nested"]; return $prevArray ? [$key => $prevArray] : [$key]; }, null);
Standard input is empty
Array
(
[I] => Array
(
[need] => Array
(
[this] => Array
(
[to] => Array
(
[be] => Array
(
[0] => nested
)
)
)
)
)
)
array(1) {
["I"]=>
array(1) {
["need"]=>
array(1) {
["this"]=>
array(1) {
["to"]=>
array(1) {
["be"]=>
array(1) {
[0]=>
string(6) "nested"
}
}
}
}
}
}