时间:2021-07-01 10:21:17 帮助过:19人阅读
$a = array(array(7,5),array(7,6,1),array(7,6,2,3,5),array(7,6,2,3,6));
$root = array();
foreach($a as $item) {
$p =& $root;
foreach($item as $k) {
if(!isset($p[$k])) $p[$k] = array();
$p =& $p[$k];
}
}
print_r($root);
Array
(
[7] => Array
(
[5] => Array
(
)
[6] => Array
(
[1] => Array
(
)
[2] => Array
(
[3] => Array
(
[5] => Array
(
)
[6] => Array
(
)
)
)
)
)
)