I can not figure out why this thing won't work properly.
I am sending this URL String:
http://www.mysite.com/buildfile.php?division=austin&XMLFormat=1
here is how I'm handling the file:
if ($_GET["XMLFormat"] <> '')
{
$xmlformat = true;
} else {
$xmlformat = false;
}
and a little later:
foreach($austin as $k => $aust) {
$aust["gamedate"] = date('l, M j', strtotime($aust["gamedate"]));
$aust["home"] = preg_replace("|\([A-Z]\)|", "", $aust["home"]);
$aust["visitor"] = preg_replace("|\([A-Z]\)|", "",$aust["visitor"]);
if ($xmlformat)
{
$js[] = " new Array(\"".$aust["gamedate"]."\",\n".
" \"".$aust["home"]."\",\"".
$aust["hscore"]."\",\"".
$aust["hwins"]."\",\"".
$aust["hloss"]."\",\"".
$aust["hties"]."\",\n".
" \"".$aust["visitor"]."\",\"".
$aust["vscore"]."\",\"".
$aust["vwins"]."\",\"".
$aust["vloss"]."\",\"".
$aust["vties"]."\")";
} else {
$js = $js."\n\t<game>\n\t\t<gamedate>".$aust["gamedate"]."</gamedate>\n".
"\t\t<home>".$aust["home"]."</home>\n".
"\t\t<hscore>".$aust["hscore"]."<hscore>\n".
"\t\t<hwins>".$aust["hwins"]."</hwins>\n".
"\t\t<hlosses>".$aust["hloss"]."</hlosses>\n".
"\t\t<hties>".$aust["hties"]."</hties>\n".
"\t\t<visitor>".$aust["visitor"]."</visitor>\n".
"\t\t<vscore>".$aust["vscore"]."</vscore>\n".
"\t\t<vwins>".$aust["vwins"]."</vwins>\n".
"\t\t<vlosses>".$aust["vloss"]."</vlosses>\n".
"\t\t<vties>".$aust["vties"]."</vties>\n\t</game>";
}
}
if ($xmlformat)
{
$js = "austin = new Array(\"Austin\",\n".implode(",\n\n", $js)."\n)";
$fp = fopen("austin.js", "w");
} else {
$js = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" standalone=\"yes\"?>\n<austin>".$js."\n</austin>";
$fp = fopen("austin.xml", "w");
}
fwrite($fp, $js);
fclose($fp);
}
No matter what I try, I can not get this thing to correctly build the
right file based on the XMLFormat variable. The above URL
produces the XML file using the code above
GET Values echoed:
Division: austin
GET["XMLFormat"]: 1
$xmlformat: 1
I've tried vaious things like
if !isset($xmlformat))
if (isset($xmlformat))
if ($xmlformat)
if ($xmlformat <> '1')
but still I either always get the js file or always get the XML file. It
does not take into consideration what the value of the
XMLFormat URI variable is.