- Notifications
You must be signed in to change notification settings - Fork8k
Closed
Description
Description
The following code:
<?php$xml ="<root><a>1</a><a>2</a></root>";$xml =simplexml_load_string($xml);$a =$xml->a;foreach ($aas$test) {var_dump((string)$a->current());var_dump((string)$a);}
Resulted in this output:
an infinite loop
But I expected this output instead:
string(1) "1"string(1) "1"string(1) "2"string(1) "1"
I think at least, because $a always refers to the first element implicitly, and only current points to the current iterated-over item?
This is basically the same as#12192, but triggered in a different yet similar way.
PHP Version
PHP 8.1+
Operating System
Linux