#27115 [Opn]: simplexml object updating array entry not working
| From: | gerry dot rodman at ness-usa dot com | Date: | Sun, 01 Feb 2004 22:46:50 +0000 |
| Subject: | #27115 [Opn]: simplexml object updating array entry not working | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-54265@lists.php.net to get a copy of this message | ||
ID: 27115
User updated by: gerry dot rodman at ness-usa dot com
Reported By: gerry dot rodman at ness-usa dot com
Status: Open
Bug Type: XML related
Operating System: win 2003
-PHP Version: 4CVS-2004-02-01 (stable)
+PHP Version: 5CVS-2004-02-01 (dev)
New Comment:
Reported at first with version 4 but am running latest v5 and changed
version to reflect this.
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