我有 2 个长度/深度未知的数组,看起来像这样
[1] => Hand Tools
[2] => Power Tools
[4] => ╚═►Outdoor Tools
[6] => ╚═►dvjdg
[5] => ╚═►Indoor Tools
[7] => ╚═►blaha
[8] => ╚═►blahb
[3] => Garden Tools
和
[1] => 0
[2] => 0
[4] => 1
[6] => 2
[5] => 1
[7] => 2
[8] => 2
[3] => 0
两个数组都使用 acategory id
作为数组索引,第二个数组包含每个类别的深度。第一个数组用于生成 HTML<select>
输入,但我现在需要按字母顺序排列这个数组,同时保持正确的类别层次结构。所以我需要得到一个这样的输出数组。
[3] => Garden Tools
[1] => Hand Tools
[2] => Power Tools
[5] => ╚═►Indoor Tools
[7] => ╚═►blaha
[8] => ╚═►blahb
[4] => ╚═►Outdoor Tools
[6] => ╚═►dvjdg
我怎样才能做到这一点?