$tree = [{"id":1,"name":"\u7535\u8111","pid":0,"level":0,"son":[{"id":3,"name":"\u7b14\u8bb0\u672c","pid":1,"level":1,"son":[{"id":7,"name":"\u8d85\u7ea7\u672c","pid":3,"level":2,"son":[]},{"id":8,"name":"\u6e38\u620f\u672c","pid":3,"level":2,"son":[]}]},{"id":4,"name":"\u53f0\u5f0f\u673a","pid":1,"level":1,"son":[]}]},{"id":2,"name":"\u624b\u673a","pid":0,"level":0,"son":[{"id":5,"name":"\u667a\u80fd\u673a","pid":2,"level":1,"son":[]},{"id":6,"name":"\u529f\u80fd\u673a","pid":2,"level":1,"son":[]}]}]
假如有这样一个树状结构数组,我想把它重新排序
用level来划分 例如level为0的数据放到一个数组,level为1放到一个数组,level可能有无限个,son也可能有无限过 用php可以实现到吗? 求实现代码
一般这种都是用递归的,给你一个js 的例子