ID: 50670
Comment by: matth at mlalonde dot net
Reported By: niklas at frubar dot net
Status: Open
Bug Type: SimpleXML related
Operating System: Linux 2.6.9 x86_64
PHP Version: 5.3.1
New Comment:
Same results in 5.2.9 as with 5.2.12.
Previous Comments:
------------------------------------------------------------------------
[2010-01-05 19:37:23] niklas at frubar dot net
It works with other array values, if you replace
$list[] = $node->attributes();
with
$c = array();
$list[] = $c;
it resets the iteration at the same node.
$list[] = array();
does not reset the iteration however.
$list[] = new stdClass();
does reset the iteration.
Adding simple integers or strings to the array do not reset.
------------------------------------------------------------------------
[2010-01-05 18:57:45] niklas at frubar dot net
Description:
------------
When iterating over a large xml object and storing attributes of all
nodes in an array, somehow the iteration gets reset (always at the same
element)
Tested with 5.3.1 and php-5.3 svn HEAD, does not occur on php-5.2.12.
Reproduce code:
---------------
<?php
function traverse($node)
{
static $list;
foreach ($node->children() as $child) traverse($child);
$list[] = $node->attributes();
echo $node['id'] . "\n";
}
traverse(new SimpleXMLElement('data.xml', null, true));
data.xml:
<?xml version="1.0"?>
<rowset>
<row id="1" />
[...]
<row id="14999" />
</rowset>
Expected result:
----------------
1
2
3
[.. continuous numbers ..]
14997
14998
14999
Actual result:
--------------
1
2
3
[.. continuous numbers ..]9994
9995
9996
2
3
4
[.. continuous numbers ..]
14997
14998
14999
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50670&edit=1