jemz Posted May 10, 2012 Share Posted May 10, 2012 Hi, can i ask is it possible to use php array in my simple menu?Can you give me some pointers what should i do so that i can have idea. Home || pictures || about me Link to comment Share on other sites More sharing options...
birbal Posted May 10, 2012 Share Posted May 10, 2012 can you explain more what you are trying to do? Link to comment Share on other sites More sharing options...
jemz Posted May 10, 2012 Author Share Posted May 10, 2012 @birbal,i want to create menu using php,when i am going to click the about me i will go to the about me page,but i want my menu to be array is this possible to do in php? Link to comment Share on other sites More sharing options...
Don E Posted May 10, 2012 Share Posted May 10, 2012 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']; Link to comment Share on other sites More sharing options...
jemz Posted May 11, 2012 Author Share Posted May 11, 2012 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? Link to comment Share on other sites More sharing options...
Ingolme Posted May 11, 2012 Share Posted May 11, 2012 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 More sharing options...
jemz Posted May 12, 2012 Author Share Posted May 12, 2012 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 More sharing options...
Ingolme Posted May 12, 2012 Share Posted May 12, 2012 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. foreach() loop PHP arrays Link to comment Share on other sites More sharing options...
jemz Posted May 13, 2012 Author Share Posted May 13, 2012 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. foreach() loop PHP arrays 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 More sharing options...
jemz Posted June 30, 2012 Author Share Posted June 30, 2012 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. foreach() loop PHP arrays 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 More sharing options...
Ingolme Posted June 30, 2012 Share Posted June 30, 2012 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 More sharing options...
jemz Posted June 30, 2012 Author Share Posted June 30, 2012 Hi, okay i will try this and i will let you know if it is working... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.