Reputation: 1546
I have used is_array many times. The variable is an array, see my code, but when i use is_array function it returned false
Any Ideas?
Here is my code.
public function updateCategories($array = null)
{
echo gettype($array); // echos array
if($array = null)
{
return false;
}
if(!is_array($array))
{
echo "false"; // echos false
return false;
}
foreach($array as $key => $val)
{
foreach($val as $Property => $Value)
{
if(!$this->updateCategoryProperty($key, $Property, $Value))
{
return false;
}
}
}
}
Upvotes: 1
Views: 3682
Reputation: 12292
Additionally to Russel Dias answer: always write your "null-checks" in this way:
if (null == $my_var)
now, if missing one "=", this will always get a real error, because you cannot assign something to null.
Upvotes: 1