#27115 [Opn->Ver]: simplexml object updating array entry not working
| From: | sniper@php.net | Date: | Mon, 02 Feb 2004 08:12:55 +0000 |
| Subject: | #27115 [Opn->Ver]: simplexml object updating array entry not working | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-54279@lists.php.net to get a copy of this message | ||
ID: 27115
Updated by: sniper@php.net
Reported By: gerry dot rodman at ness-usa dot com
-Status: Open
+Status: Verified
Bug Type: XML related
Operating System: win 2003
PHP Version: 5CVS-2004-02-01 (dev)
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