FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » option values with php foreach not working
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
option values with php foreach not working [message #171112] Sat, 25 December 2010 02:58 Go to previous message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma:
Senior Member
When I run this code locally I get, in firefox, a listbox with "adam" as
the only output. Nothing else. The second array doesn't even show.

In IE, both items show but I get a warning saying "invalid argument -
foreach".
The second array shows up after the warning.

What am I missing?

Dear Santa,

Please bring lots of coal! We need the heat!




<select name="menu1" size="10">
<option value="101">adam</option>

<?php

$myArray="(1,2,3,4,5)";
foreach ($myArray as $myItem) {
echo "<option value='$myItem'>$myItem</option>\n"; }

$arr = array("one", "two", "three");
foreach ($arr as $key => $value) {
echo "Key: $key; Value: $value<br />\n";
}


?>


</select>
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: Slowly coming together
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sun Nov 24 07:33:47 GMT 2024

Total time taken to generate the page: 0.04117 seconds