#27115 [NEW]: simplexml object updating array entry not working
| From: | gerry dot rodman at ness-usa dot com | Date: | Sun, 01 Feb 2004 22:41:12 +0000 |
| Subject: | #27115 [NEW]: simplexml object updating array entry not working | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-54264@lists.php.net to get a copy of this message | ||
From: gerry dot rodman at ness-usa dot com
Operating system: win 2003
PHP version: 4CVS-2004-02-01 (stable)
PHP Bug Type: XML related
Bug description: simplexml object updating array entry not working
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 bug report at http://bugs.php.net/?id=27115&edit=1
--
Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27115&r=trysnapshot4
Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27115&r=trysnapshot5
Fixed in CVS: http://bugs.php.net/fix.php?id=27115&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=27115&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=27115&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=27115&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=27115&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=27115&r=support
Expected behavior: http://bugs.php.net/fix.php?id=27115&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=27115&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=27115&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=27115&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27115&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=27115&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=27115&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=27115&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27115&r=float