ID: 37817
Updated by: [EMAIL PROTECTED]
Reported By: ecervetti at ch-hyeres dot fr
-Status: Open
+Status: Assigned
Bug Type: SimpleXML related
Operating System: Linux mandriva 2006
PHP Version: 5.1.4
-Assigned To:
+Assigned To: helly
New Comment:
Verified with 5.2
Previous Comments:
------------------------------------------------------------------------
[2006-06-15 12:24:42] ecervetti at ch-hyeres dot fr
Description:
------------
I try to access a particular element of xml data with the
foreach($xml->name_of_element ....) syntax.
But I don't know if this element exists.
When the element don't exists, no problem the first time;
It don't goes inside the loop.
But If I call the same loop a second time, it goes inside the loop, as
if the element exists.
Reproduce code:
---------------
$string =
"<data><typebal1>pim</typebal1><typebal2>poom</typebal2></data>";
$xml = simplexml_load_string($string);
foreach($xml->typebal3 as $bal) {
print "<br />I should not be here<br />";
}
foreach($xml->typebal3 as $bal) {
print "<br />I should either not be here<br />";
}
//this script renders "I should either not be here"
Expected result:
----------------
this script should not print anything
Actual result:
--------------
this script renders "I should either not be here"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37817&edit=1