Turn database result into array

前端 未结 5 985
忘掉有多难
忘掉有多难 2020-11-28 09:19

I have just made the update/add/delete part for the \"Closure table\" way of organizing query hierarchical data that are shown on page 70 in this slideshare: http://www.slid

5条回答
  •  情话喂你
    2020-11-28 09:45

    When you want the output as a unordered list you can change the outputCategories method as follows (based on ftrotters arrays in arrays):

    public function outputCategories($categories, $startingLevel = 0)
    {
        echo "
      \n"; foreach ($categories as $key => $category) { if (count($category['children']) > 0) { echo "
    • {$category['name']}\n"; $this->outputCategories($category['children'], $startingLevel+1); echo "
    • \n"; } else { echo "
    • {$category['name']}
    • \n"; } } echo "
    \n"; }

提交回复
热议问题