|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27115 simplexml object updating array entry not working
Submitted: 2004-02-01 17:41 UTC Modified: 2004-02-11 11:58 UTC
Avg. Score:4.7 ± 0.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: gerry dot rodman at ness-usa dot com Assigned:
Status: Closed Package: XML related
PHP Version: 5CVS-2004-02-06 OS: *
Private report: No CVE-ID: None
 [2004-02-01 17:41 UTC] gerry dot rodman at ness-usa dot com
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:
$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 changed 
<the first gerry should be gerry changed>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-11 11:58 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Apr 13 21:01:23 2021 UTC