I am trying to perform count on SimpleXML Element. It si giving me different results on PHP 5.3 and PHP 5.2. My code looks like follows :
$xml = new SimpleXMLElement('<command action="foo"/>');
print_r(count((array)$xml->children()));`
On PHP 5.2 the above prints "1" and on PHP 5.3 it prints "0" :(
I know I can use $xml->count
but that does not take ino account the root element of the XML.
Just wondering what might be wrong in type casting the SimpleXML to array in PHP 5.3