i keep getting this error
Warning: Invalid argument supplied for foreach() in ...\functions.php on line 448
this is the code
foreach($holidays as $key => $value)
Are you sure $holidays is an array and holds some values?
Yes, I am sure $holidays is an array. Could it be the fact that i never actually declared it as an array? I merely did like $holidays[] = bla bla somewhere along the line and it became an array. How do I declare an array tho? just like array $holidays like that?
$holidays = array();
That will setup $holidays as an array...
thx! ill see if that fixes the problem
If you just wanna check to see if something is an array, use is_array($var)
o yea thats rite... :o
Other fun array tricks:
print implode("::",array_keys($array)); print implode("::",array_values($array));
So before using foreach (especially on variables that may or may not be arrays, or may or may not hold values), you should check both is_array() and count() as if no values exist you should do something else (like yell at the user!).
Originally posted by philipolson So before using foreach (especially on variables that may or may not be arrays, or may or may not hold values), you should check both is_array() and count() as if no values exist you should do something else (like yell at the user!).
lol ill remember that!