hi,
i am having problems with the "str_replace" code
i am working on an xbox forum and it will get your gamerDetails
i have an input box with the name "GamerTag" and my form is set to GET
but if you have spaces in your Gamertag it replaces them with a "+"
E.G. index.php?GamerTag=1+2+3
but i want them to be "%20"
E.G. index.php?GamerTag=1%202%203
i used this code thinking it would work but it doesnt
<?php
if(@$_GET['GamerTag']) {
// i used this to replace + with %20 but it doesn't work
$gamertag = str_replace('+', '%20', $_GET['GamerTag']);
$ch = curl_init("http://xboxapi.duncanmackenzie.net/gamertag.ashx?GamerTag=".$gamertag."");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 4);
$data = curl_exec($ch);
curl_close($ch);
$xml = new SimpleXmlElement($data, LIBXML_NOCDATA);
print $xml->Gamertag;
print "<br>";
print "".$xml->PresenceInfo->StatusText.": ".$xml->PresenceInfo->Info;
if(@$xml->PresenceInfo->Info2) {
print " - ".$xml->PresenceInfo->Info2;
}
?>