#27115 [Ver->Csd]: simplexml object updating array entry not working
| From: | rrichards@php.net | Date: | Wed, 11 Feb 2004 16:58:42 +0000 |
| Subject: | #27115 [Ver->Csd]: simplexml object updating array entry not working | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-54757@lists.php.net to get a copy of this message | ||
ID: 27115
Updated by: rrichards@php.net
Reported By: gerry dot rodman at ness-usa dot com
-Status: Verified
+Status: Closed
Bug Type: XML related
Operating System: *
PHP Version: 5CVS-2004-02-06
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2004-02-01 17:41:12] gerry dot rodman at ness-usa dot com
Description:
------------
I cant seem to change the value of an array entry in a simple xml
object if I use a variable for an index.
But it changes OK if I use a constant.
Reproduce code:
---------------
<?php
$xmlstr =
"<root><people><name>gerry</name><name>barbara</name></people></root>";
$xml = simplexml_load_string($xmlstr);
$i = 0;
$xml->people->name[$i] = "gerry changed"; // sorry, gerry doesnt
change if variable is used as index (bug?)
echo $xml->people->name[0];
echo "<br>";
$xml->people->name[0] = "gerry changed"; // gerry does change is a
constant is supplied
echo $xml->people->name[0];
?>
Expected result:
----------------
gerry changed
gerry changed
Actual result:
--------------
gerry
gerry changed
<the first gerry should be gerry changed>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=27115&edit=1