Jump to content

Menu Generation


HDFilmMaker2112

Recommended Posts

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
Share on other sites

<?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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.