Jump to content

Menu(php)


jemz
 Share

Recommended Posts

can you explain more what you are trying to do?

Link to comment
Share on other sites

You mean something like this: Ex:

$menu = array("Home" => "index.php", "Services" => "services.php",  "About" => "about.php",  "Contact" => "contact.php");

That's an associative array. To get index.php: $menu['Home'];

Edited by Don E
Link to comment
Share on other sites

You mean something like this: Ex:
$menu = array("Home" => "index.php", "Services" => "services.php",  "About" => "about.php",  "Contact" => "contact.php");

That's an associative array. To get index.php: $menu['Home'];

Hi,Thank you for this,yes this is it what i am looking for so how can i access the about.php using this array,is this an efficient way to use?
  • Like 1
Link to comment
Share on other sites

You don't need to worry about efficiency with this kind of thingUse a foreach() loop to access all the elements:

foreach($menu as $name => $url) {    echo "Link name: {$name}<br>Link url: {$url}";}

Link to comment
Share on other sites

You don't need to worry about efficiency with this kind of thingUse a foreach() loop to access all the elements:
foreach($menu as $name => $url) {	echo "Link name: {$name}<br>Link url: {$url}";}

Okay,thank you for the reply,so how can i get to other page in this array?for example in about.php ,can i use isset()?
Link to comment
Share on other sites

You mean to show a link? Just print the link:

echo '<a href="URL">Link name</a>';

If I went any further here I'd be doing it for you and you wouldn't learn anything. I suggest looking through the PHP tutorials and the manual because this is really simple.

  • Like 1
Link to comment
Share on other sites

You mean to show a link? Just print the link:
echo '<a href="URL">Link name</a>';

If I went any further here I'd be doing it for you and you wouldn't learn anything. I suggest looking through the PHP tutorials and the manual because this is really simple.

Hi,Thank you don't worry i am not kind of man asking help without coding,actually i made the code now.and also i am reading other tutorial.thank you again and i will write again to you if i have doubt.
Link to comment
Share on other sites

  • 1 month later...
You mean to show a link? Just print the link:
echo '<a href="URL">Link name</a>';

If I went any further here I'd be doing it for you and you wouldn't learn anything. I suggest looking through the PHP tutorials and the manual because this is really simple.

Hi, I am back about the menu in associative array. Okay how can i do this to show something like this in the URL example. index.php?fpage=home how can i do that. Thank you in advance.
Link to comment
Share on other sites

It's all part of the URL string, just add that to the URL that's already in your array.

array(  'Home'    => 'index.php?fpage=home',  'Contact' => 'index.php?fpage=contact')

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...