mmccracken Posted July 10, 2010 Share Posted July 10, 2010 Hi All, -Background: Creating a game in flash, where if the player gets enough points, enters into the highscore, which is stored in an xml file. Below is the snippet where my php problem/lack of knowledge is, while the attached file contains the php file that reads the xml content, checks where in the xml score list the new entry should go, and then pushes everything down one level and disregards the last entry as there's a new entry, to keep the full amount of entries to 20. Problem: The variables that holds the old values for where the new position goes, changes without me changing it. Is the variable just pointing to where it's created from. How do I solidly make it "it's own" and not a reference? If not is correct, what am I doing wrong/missunderstanding? $oldTempName = $myXml->score[$newScorePosition - 1]->meta[0]; $oldTempScore = $myXml->score[$newScorePosition - 1]->points; // this returns the original value: echo "missing should be here : " . $oldTempName . " and " . $oldTempScore . "<br />"; $myXml->score[$newScorePosition - 1]->meta[0] = $fakeName; $myXml->score[$newScorePosition - 1]->points = $fakeScore; // this returns the $fakeName & $fakeScore, not the original value: echo "missing should be here : " . $oldTempName . " and " . $oldTempScore . "<br />"; attaching full php script + xml file as a .txt file. [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/207316-simplexml-vars-containing-references-not-values/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.