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? Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
play_ Posted October 14, 2006 Author Share Posted October 14, 2006 many thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.