我已经为此工作了一段时间。我看到 php 中的多级数组并不容易。这是我的代码:
Array
(
[0]=array(
"level"=>'Level1',
"id"=>1,
"title"=>"Home",
"order"=>"0"
);
[1]=array(
"level"=>'Level1',
"id"=>"355",
"title"=>"About Us",
"order"=>"21"
);
[2]=array(
"level"=>'Level1',
"id"=>"10",
"title"=>"Test",
"order"=>"58"
);
[3]=array(
"level"=>'Level2',
"id"=>13,
"title"=>"Our Team",
"order"=>"11",
"parent_id"=>"355"
);
[4]=array(
"level"=>'Level2',
"id"=>12,
"title"=>"The In Joke",
"order"=>"12",
"parent_id"=>"355"
);
[5]=array(
"level"=>'Level2',
"id"=>11,
"title"=>"Our History",
"order"=>"13",
"parent_id"=>"355"
));
>
1-Home
2-about us
3-Our Team
4-The In Joke
5-Our History
6-Test
我有多级父子数组,需要根据关于结果排序不明白如何使用usort()
。