PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Sun Jul 04, 2004 4:59 pm
is there anyway to see if a foreach statement has no vars.
I am trying to avoid this:
Warning: Invalid argument supplied for foreach() in /home/theory/yada on line 59
I want to create a warning, like "There were no items selected" but my attempted have been for the no good.
kudos
markl999
DevNet Resident
Posts: 1972 Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)
Post
by markl999 » Sun Jul 04, 2004 5:01 pm
Code: Select all
if(is_array($foo) && !empty($foo)){
foreach($foo as $bar){
....
}
}
?
tim
DevNet Resident
Posts: 1165 Joined: Thu Feb 12, 2004 7:19 pm
Location: ohio
Post
by tim » Sun Jul 04, 2004 5:02 pm
i'll try it, i tried the empty() and a few of the array handlers.
i'll let ya know, thanks mark.