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
Re: option values with php foreach not working [message #171114 is a reply to message #171112] Sat, 25 December 2010 03:25 Go to previous messageGo to previous message
richard is currently offline  richard   
Messages: 213
Registered: June 2013
Karma:
Senior Member
On Fri, 24 Dec 2010 19:58:56 -0700, richard wrote:

> 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>

Notice I had the second array where it shouldn't be and moved it out of
that part.

Still I get a warning for an invalid argument foreach.
[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: Wed Nov 27 08:37:31 GMT 2024

Total time taken to generate the page: 0.04945 seconds