{
php_sxe_object *sxe;
xmlNodePtr node;
+ zval *data;
*count = 0;
sxe = php_sxe_fetch_object(object TSRMLS_CC);
+
+ data = sxe->iter.data;
+ sxe->iter.data = NULL;
+
node = php_sxe_reset_iterator(sxe, 0 TSRMLS_CC);
while (node)
node = php_sxe_iterator_fetch(sxe, node->next, 0 TSRMLS_CC);
}
+ if (sxe->iter.data) {
+ zval_ptr_dtor(&sxe->iter.data);
+ }
+ sxe->iter.data = data;
return SUCCESS;
}
--- /dev/null
+--TEST--
+SimpleXML: foreach and count
+--SKIPIF--
+<?php if (!extension_loaded("simplexml")) print "skip"; ?>
+--FILE--
+<?php
+$xml =<<<EOF
+<people>
+ <person name="Joe"/>
+ <person name="John">
+ <children>
+ <person name="Joe"/>
+ </children>
+ </person>
+ <person name="Jane"/>
+</people>
+EOF;
+
+$people = simplexml_load_string($xml);
+
+foreach($people as $person)
+{
+ var_dump((string)$person['name']);
+ var_dump(count($people));
+ var_dump(count($person));
+}
+
+?>
+===DONE===
+--EXPECTF--
+string(3) "Joe"
+int(3)
+int(0)
+string(4) "John"
+int(3)
+int(1)
+string(4) "Jane"
+int(3)
+int(0)
+===DONE===
+--UEXPECTF--
+unicode(3) "Joe"
+int(3)
+int(0)
+unicode(4) "John"
+int(3)
+int(1)
+unicode(4) "Jane"
+int(3)
+int(0)
+===DONE===