Home >Backend Development >PHP Tutorial >父子列表的array排序方法解决思路

父子列表的array排序方法解决思路

WBOY
WBOYOriginal
2016-06-13 10:06:111341browse

父子列表的array排序方法
$list_arr=array(array('id'=>1,'sort'=>1,'parentid'=>0),
  array('id'=>2,'sort'=>3,'parentid'=>1),
  array('id'=>3,'sort'=>2,'parentid'=>1),
  array('id'=>4,'sort'=>4,'parentid'=>0)

id=1 //父
  id=3 //子
  id=2 //子 
id=4 //父

------解决方案--------------------
去参考徐老大发的帖子:
http://topic.csdn.net/u/20110728/15/eadffb68-5eb6-40d8-9ec1-2bc439f45322.html?39575

或者你用递归也可以实现。。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn