Check If array is null or not in php

you can use

empty($result) 

to check if the main array is empty or not.

But since you have a SimpleXMLElement object, you need to query the object if it is empty or not. See http://www.php.net/manual/en/simplexmlelement.count.php

ex:

if (empty($result)) {
    return false;
}
if ( !($result['Tags'] instanceof SimpleXMLElement)) {
    return false;
}
return ($result['Tags']->count());

This checks if the variable is not set or contains a falsey value (zero, empty string, empty array, etc)

if (!empty($result) {
    // do stuff if the variable is not empty
} else {
    // do stuff if the variable is empty
}

This checks if the the variable is null

if (is_null($result) {
   // do stuff if the variable is null
} else {
   // do stuff if the variable is not null
}

Tags:

Php

Arrays

Null