#37875 [Opn->Ver]: while(list() = each() ) on simplexml_element loops forever

From: Date: Thu, 22 Jun 2006 19:30:57 +0000
Subject: #37875 [Opn->Ver]: while(list() = each() ) on simplexml_element loops forever
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-98686@lists.php.net to get a copy of this message
ID: 37875 Updated by: tony2001@php.net Reported By: jona at oismail dot com -Status: Open +Status: Verified Bug Type: SimpleXML related Operating System: Windows 2000 PHP Version: 5.1.4 Previous Comments: ------------------------------------------------------------------------ [2006-06-21 15:24:29] jona at oismail dot com Description: ------------ When doing a while (list($key, $val) = each($obj_XML) ) on a Simple XML object PHP loops forever. Is this possibly related bug: #24945 foreach on simplexml_element loops forever? Please note, for each works but only output the tag not the attribute. Found on Windows 2000 running IIS with PHP5.1.4 as an ISAPI module. Reproduce code: --------------- <?php $sXML = '<?xml version="1.0" encoding="ISO-8859-5"?> <root type="input"> <username>Jona</username> </root>'; $obj_XML = simplexml_load_string($sXML); while (list($key, $val) = each($obj_XML) ) { echo $key ." - "; if(is_array($val) === true) { while (list($k, $v) = each($val) ) { echo $k ." - ". $v; } } else { echo $val; } echo "<br />"; } ?> Expected result: ---------------- @attributes - type - input username - Jona Actual result: -------------- @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input @attributes - type - input etc. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37875&edit=1

« previous php.bugs (#98686) next »