HDFilmMaker2112 Posted June 24, 2011 Share Posted June 24, 2011 The below is out putting: FilmsWebseriesCompany - >?films FilmsWebseriesCompany - >?webseries FilmsWebseriesCompany - >?company I need it to iterate through each link name once. <?php // define menus $menu = array(); $menu['user_investor'] = array("Films" => "$page.php?films","Webseries" => "$page.php?webseries","Company" =>"$page.php?company"); $menu['user_donor'] = array("<a href='$page.php?contact'>Contact</a>","<a href='index.php?faq'>FAQ</a>","<a href='http://store.makethemoviehappen.com'>Store</a>"); $menu['user_other'] = array("<a href='$page.php?donate'>Donate</a>","<a href='$page.php?contact'>Contact</a>","<a href='$page.php?faq'>FAQ</a>"); // logic to determine which menu to use if(isset($_GET['test'])){ $type = 'user_investor'; $menu_text = array_keys($menu['user_investor']); } elseif(isset($_SESSION['myusername2'])){ $type = 'user_donor'; $menu_text = array_keys($menu['user_donor']); } else { $type = 'user_other'; $menu_text = array_keys($menu['user_other']); } // produce and output the correct menu foreach($menu[$type] as $link){ echo "<div class='tab'>"; echo '<a href="'.$link.'">'; for($i=0; $i <= count($menu_text); $i++){ echo $menu_text[$i]; } echo '</a>'; echo "</div>"; } ?> \ Link to comment https://forums.phpfreaks.com/topic/240288-menu-generation/ Share on other sites More sharing options...
HDFilmMaker2112 Posted June 24, 2011 Author Share Posted June 24, 2011 <?php // define menus $menu = array(); $menu['user_investor'] = array("Films" => "$page.php?films","Webseries" => "$page.php?webseries","Company" =>"$page.php?company"); $menu['user_donor'] = array("<a href='$page.php?contact'>Contact</a>","<a href='index.php?faq'>FAQ</a>","<a href='http://store.makethemoviehappen.com'>Store</a>"); $menu['user_other'] = array("<a href='$page.php?donate'>Donate</a>","<a href='$page.php?contact'>Contact</a>","<a href='$page.php?faq'>FAQ</a>"); // logic to determine which menu to use if(isset($_GET['test'])){ $type = 'user_investor'; } elseif(isset($_SESSION['myusername2'])){ $type = 'user_donor'; } else { $type = 'user_other'; } $menu_text = array_keys($menu[$type]); // produce and output the correct menu $i=0; foreach(array_values($menu[$type]) as $link){ echo '<div class="tab">'; echo '<a href="'.$link.'">'; echo $menu_text[$i]; echo '</a>'; echo "</div>"; $i++; } ?> Link to comment https://forums.phpfreaks.com/topic/240288-menu-generation/#findComment-1234222 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.