Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>tested, working...</p> <pre><code>&lt;?php $MENU=array(); $MENU["HOME"] = array ( 'parent'=&gt;true, // parent == true ? show in top level menu : do not show in top level 'enabled'=&gt;true, 'text'=&gt;'Home', 'link'=&gt; 'public/home', 'sub_modules' =&gt; array() // empty sub modules means no sub menus need to display ); $MENU["SHOP"] = array ( 'parent'=&gt;true, 'enabled'=&gt;true, 'text'=&gt;'Shop', 'link'=&gt; 'public/shop', 'sub_modules' =&gt; array('SALES') // SALES is a sub menu of SHOP,which is also configured as another module ); $MENU["SALES"] = array ( 'parent'=&gt;FALSE, // PARENT = FALSE (this is a sub menu of SHOP) 'enabled'=&gt;true, 'text'=&gt;'Sales', 'link'=&gt; 'public/shop/sales', 'sub_modules' =&gt; array('SALES_RETURN','SALES_REPORT') //have 2 sub menu's ); $MENU["SALES_RETURN"] = array ( 'parent'=&gt;FALSE, 'enabled'=&gt;true, 'text'=&gt;'Sales Return', 'link'=&gt; 'public/shop/sales/return', 'sub_modules' =&gt; array() ); $MENU["SALES_REPORT"] = array ( 'parent'=&gt;FALSE, 'enabled'=&gt;true, 'text'=&gt;'Sales Report', 'link'=&gt; 'public/shop/sales/report', 'sub_modules' =&gt; array() ); function show_menu(&amp;$MENU,$subIndex=false){ $menu_string = '&lt;UL&gt;'; if(!$subIndex){ foreach($MENU as $item) { if( $item['enabled']&amp;&amp;$item['parent'] ) { $_subString=""; if(!empty($item['sub_modules'])){ foreach($item['sub_modules'] as $sub){ $_subString .= show_menu($MENU,$sub); } } $menu_string .= '&lt;LI&gt;'.$item['text'].$_subString.'&lt;/LI&gt;'; } } }else{ if(@$MENU[$subIndex]['enabled']&amp;&amp;!@$MENU[$subIndex]['parent']) { $_subString=""; if(!empty($MENU[$subIndex]['sub_modules'])){ foreach($MENU[$subIndex]['sub_modules'] as $sub){ $_subString .= show_menu($MENU,$sub); } } $menu_string .= '&lt;LI&gt;'.$MENU[$subIndex]['text'].$_subString.'&lt;/LI&gt;'; } } return $menu_string.'&lt;/UL&gt;'; } echo show_menu($MENU); ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload