从mysql表创建多维 array

从mysql表创建多维 array


$output = array();
$sections = $this->_model->get_table_sections();

foreach($sections as $section){
 $output[$section->section_title] = array();

 $rubriques = $this->_model->get_rubriques_for_a_section($section->section_id);

 foreach($rubriques as $rubrique){
 $output[$section->section_title][$rubrique->rubrique_title] = array();

 $categories = $this->_model->get_categ_for_a_section_and_a_rubrique($section->section_id,$rubrique->rubrique_id);
 foreach($categories as $categorie){
 $output[$section->section_title][$rubrique->rubrique_title][] = $categorie->categorie_title;
 }
 }
}

var_dump($output);

你可能感兴趣的:(从mysql表创建多维 array)