ID: 34422 Updated by: [EMAIL PROTECTED] Reported By: cyberline at techno4ever dot net -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: Suse 9.3 PHP Version: 5.0.5 New Comment:
use $hosts[] = (string) $listener->HOSTNAME; $listener->HOSTNAME is an object, echo just automatically calls the internal __toString() Previous Comments: ------------------------------------------------------------------------ [2005-09-08 09:50:52] cyberline at techno4ever dot net Description: ------------ When adding a subelement of the xml object to an array, it becomes an object again? "echo" doesn't return an object ... Reproduce code: --------------- $xml = simplexml_load_string($this->xml); foreach($xml->LISTENERS->LISTENER as $listener) { echo $listener->HOSTNAME; // Last element in tree $hosts[] = $listener->HOSTNAME; } Expected result: ---------------- 127.0.0.1 Array( [0] => 127.0.0.1 ) Actual result: -------------- 127.0.0.1 Array( [0] => SimpleXMLElement Object( [0] => 127.0.0.1 ) ) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=34422&edit=1