Skip to content
Advertisement

Check If array is null or not in php

I have an array like below which is generated by parsing a xml url.

The array is

JavaScript

The array name is $result. Now I want to check that if the array received like above I want to print a message of failure. But how to check this array in if condition?

Advertisement

Answer

you can use

JavaScript

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:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement