Created
December 17, 2012 05:13
-
-
Save anonymous/4315906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$mysql_results = array(); | |
$results = array(); | |
foreach($mysql_results as $item) { | |
if($item['parent_id']!= 0) { | |
//如果有 parent_id, 加到 parent里 | |
array_push($results[$item['parent_id']], array('id'=>$item['id'], 'title'=> ......)); | |
} else { | |
//没有则创建 | |
array_push($results, array('id'=>$item['id'], 'title'=> ......)); | |
} | |
} | |
//后面那些点自己补充吧。。 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment