ID:               37875
 Comment by:       tys at tvg dot ca
 Reported By:      jona at oismail dot com
 Status:           Verified
 Bug Type:         SimpleXML related
 Operating System: Windows 2000
 PHP Version:      5.1.4
 New Comment:

I'm running into the same bug but on a generic php PEAR DB object which
leads me to believe this isn't specific to Simple XML objects.

PHP 5.1.2 (cgi) (built: May  1 2006 01:12:05)
mysql  Ver 14.12 Distrib 5.0.18, for pc-linux-gnu (i686) using readline
5.0


while(list($key,$val)=each($main->getData())) enters an endless loop

foreach($main->getData() as $key=>$val) works fine


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

Reply via email to