play_ Posted October 14, 2006 Share Posted October 14, 2006 I have an array and i`d like to make a dropdown from that array[code]$pages = array("Home" => "home.html", "About" => "about.html", "Crew" => "crew.html"); $arraysize = count($pages); for($i = 0; $i <= $arraysize; $i++) { foreach($key as $value) { echo '<option value="$key">$value</option>'; } }[/code]That's what i have, but it isn't working. any ideas? Link to comment https://forums.phpfreaks.com/topic/23941-quick-dropdown-menu-help/ Share on other sites More sharing options...
Orio Posted October 14, 2006 Share Posted October 14, 2006 Your foreach statement is wrong.It should be:foreach($pages as $key => $value)Also, you dont need the for loop, because the foreach does the work for you.Final code should look like:[code]<?php$pages = array("Home" => "home.html", "About" => "about.html", "Crew" => "crew.html");foreach($pages as $key => $value) echo '<option value="'.$key.'">'.$value.'</option>';?>[/code]Orio. Link to comment https://forums.phpfreaks.com/topic/23941-quick-dropdown-menu-help/#findComment-108825 Share on other sites More sharing options...
play_ Posted October 14, 2006 Author Share Posted October 14, 2006 many thanks Link to comment https://forums.phpfreaks.com/topic/23941-quick-dropdown-menu-help/#findComment-108859 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.