Recursive function to generate multidimensional array from database result

后端 未结 4 2001
后悔当初
后悔当初 2020-11-22 07:19

I\'m looking to write a function that takes an array of pages/categories (from a flat database result) and generates an array of nested page/category items based on the pare

4条回答
  •  忘了有多久
    2020-11-22 08:01

    It is possible to use php to get the mysql result into array and then use it.

    $categoryArr = Array();
    while($categoryRow = mysql_fetch_array($category_query_result)){
        $categoryArr[] = array('parentid'=>$categoryRow['parent_id'],
                'id'=>$categoryRow['id']);
       }
    

提交回复
热议问题