Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

Using foreach loop

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

Using foreach loop

Postby qadeerbk » Sun Sep 29, 2002 9:44 am

I am trying to use foreach loop on HTTP_POST_VARS
like

foreach( $HTTP_POST_VARS as $key => $value)
$list[$fieldName] = $value;
But I am getting the followinf error message on this line I mean on "foreach"

Warning: Invalid argument supplied for foreach() in .......

Any suggestion please

Thank you in advance
qadeerbk
New php-forum User
New php-forum User
 
Posts: 7
Joined: Sun Sep 29, 2002 9:36 am

Postby serge » Sun Sep 29, 2002 11:39 pm

8) Think about this code:
Code: Select all
echo "Values submitted via POST method:<br>";
while ( list( $key, $val ) = each( $HTTP_POST_VARS ) )
{
   echo "$key => $val<br>";
}


Thanx
------------------------
With best regards,
Serge Bulanov
AlarIT Web developer,
www.AlarIT.com
serge
New php-forum User
New php-forum User
 
Posts: 14
Joined: Mon Sep 16, 2002 1:25 am
Location: Ukraine

Re: Using foreach loop

Postby Jay » Sun Sep 29, 2002 11:48 pm

qadeerbk wrote:Warning: Invalid argument supplied for foreach() in .......

Sounds like the array is empty or non-existant. Use serge's code!
Jay
 


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron