php.net |  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
Votes:3
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:
 [2004-02-01 17:41 UTC] 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>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-02-11 11:58 UTC] rrichards@php.net
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.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 19:01:53 2014 UTC