I have an array like below which is generated by parsing a xml url.
The array is
Array
(
[Tags] => SimpleXMLElement Object
(
[0] =>
)
)
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?
Right code of two ppl before ^_^
This checks if the array is empty
This checks if the array is null or not
you can use
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:
Corrected;
if array is look like this [null] or [null, null] or [null, null, null, ...]
you can use implode:
implode is use for convert array to string.
I understand what you want. You want to check every data of the array if all of it is empty or at least 1 is not empty
Empty array
Array ( [Tags] => SimpleXMLElement Object ( [0] => ) )
Not an Empty array
Array ( [Tags] => SimpleXMLElement Object ( [0] =>,[1] => "s" ) )
I hope I am right. You can use this function to check every data of an array if at least 1 of them has a value.
Hope that helps.