ok Posted September 5, 2008 Share Posted September 5, 2008 Hi guys, very basic problem with foreach.. below is the codes. $multi_winner[$i] = $row['invited_by']; foreach ($multi_winner as $value2) { echo "<br>multipler_winner: ". $value2; } below is the error message. Warning: Invalid argument supplied for foreach() Thank you! Quote Link to comment Share on other sites More sharing options...
ranjuvs Posted September 5, 2008 Share Posted September 5, 2008 Try this <?php $i=0; $multi_winner[$i] = 'test'; foreach ($multi_winner as $value2) { echo "<br>multipler_winner: ". $value2; } ?> Quote Link to comment Share on other sites More sharing options...
QuietWhistler Posted September 5, 2008 Share Posted September 5, 2008 What I do to catch errors with foreach loops, is checking if the variable is actually an array. So like this: <?php $multi_winner[ $i ] = $row[ "invited_by" ]; if( is_array( $multi_winner ) { foreach( $multi_winner as $value ) { print( "stuff" ); } } ?> 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.