带有数组的PHP的多级菜单

时间:2016-08-06 14:11:24

标签: php arrays

我尝试创建一个自动菜单,但它在level1_title之后停止。 我尝试将foreach(apps ['apps1'}包含为$ app1)但它确实有效。 数据不会出现。

你有想法解决这个问题吗? 谢谢

<?php
  $cl_box_groups[] = array(
                          'level0_title' => BOX_HEADING_CONFIGURATION,
                          'level0_class' => 'fa fa-sun-o',

                          'apps' => array(
                            array(
                              'level1_title' => MENU_CONFIGURATION_STORE,
                              'level1_class' => 'fa fa-sun-o'
                            ),

                            'apps1' => array (
                              array('level12_title' => MENU_CONFIGURATION_GENERAL,
                                    'level12_class' => '',
                                    'level12_link' => 'configuration.php?gID=1',
                              ),
                              array('level13_title' => MENU_CONFIGURATION_LEGACY,
                                    'level13_class' => '',
                                    'level13_link' => 'configuration.php?gID=25',
                              ),
                            ),
                          ),
                          );

?>

    <div id="menu">
      <nav>
        <h2><i class="fa fa-reorder"></i>My Menu</h2>
        <ul>
          <a href="../index.php" target="_blank"><?php echo HEADER_TITLE_ONLINE_CATALOG; ?></a>
<?php
        foreach ($cl_box_groups as $groups) {
?>
           <li>
              <a href="#"><i class="<?php echo $groups['level0_class']; ?>"></i> <?php echo $groups['level0_title'] ;?></a>
              <h2><i class="<?php echo $groups['level0_class']; ?>"></i> <?php echo $groups['level0_title'] ;?></h2>';
              <ul>
                <h2><i class="<?php echo $groups['level0_class']; ?>"></i> <?php echo $groups['level0_title'] ;?></h2>';
<?php
          foreach ($groups['apps'] as $app) {
?>
                  <li>
                    <a href="#"><i class="<?php echo $groups['level1_class']; ?>"></i><?php echo $app['level1_title']; ?></a>
                    <h2><i class="<?php echo $groups['level1_class']; ?>"></i> <?php echo $app['level1_title']; ?></h2>
                    <ul>
                    </ul>
                  </li>
<?php
          }
?>
              </ul>
          </li>
<?php
        }
?>
        </ul>
      </nav>
    </div>

0 个答案:

没有答案