Iterating through an object... API response... for some strange reason, certain empty values are coming up as an empty array... i.e.
$foo->bar = array()
or
$foo->bar = array(0)
But when I try to check with:
if ( empty($foo->bar) )
Or even:
if ( is_array($foo->bar) )
It's not catching it. I've been converting the whole object to an array to get around this, which works, but is costing performance.
Is there something I'm missing here?
EDIT:
Going back, it looks like I mixed up my array with my object. What I NEED to check for is an empty value in a response such as:
[1] => SimpleXMLElement Object
(
[RecordID] => 14
[SomethingID] => 1
[SomethingName] => OKAY
[Integer] => 0
[String] => String
[AnotherInteger] => 1
[Empty] => SimpleXMLElement Object
(
)
[SomethingElseID] => 0
)
How do I check if $object->Empty is EMPTY?
EDIT:
var_dump shows:
object(SimpleXMLElement)#1343 (8) {
["RecordID"]=> string(2) "14"
["SomethingID"]=> string(1) "1"
["SomethingName"]=> string(4) "OKAY"
["Integer"]=> string(1) "0"
["String"]=> string(6) "String"
["AnotherInteger"]=> string(1) "1"
["Empty"]=> object(SimpleXMLElement)#1355 (0) { }
["SomethingElseID"]=> string(1) "0"
}
array(0)isn't an empty array, andempty($arr)does work.array()andarray(0))?