1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
function
getTree(
$items
) {
foreach
(
$items
as
$value
){
$value
[
'son'
] =
array
();
$new_address
[
$value
[
'id'
]] =
$value
;
}
foreach
(
$new_address
as
&
$value
){
if
(
$value
[
'pid'
] !=0){
$new_address
[
$value
[
'pid'
]][
'son'
][] = &
$value
;
}
else
{
$res_address
[
$value
[
'id'
]] = &
$value
;
}
}
return
$res_address
;
}
|
本文转自 IT阿飞 51CTO博客,原文链接:http://blog.51cto.com/itafei/1949755