Page 1 of 1

So far so good.. but need a bit of help

Posted: Fri Jan 02, 2015 11:06 am
by cowboysdude
This is what I have so far:

Code: Select all

$url="http://www.nfl.com/liveupdate/scorestrip/postseason/ss.xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);    // get the url contents

$data = curl_exec($ch); // execute curl request
curl_close($ch);

$xml = simplexml_load_string($data);
// print_r($xml);   

  foreach ($xml->gms->g as $game) 
    {
    (string)$game["htn"] = $htn;
    (string)$game["hs"]-> $hn;
    (string)$game["htn"]-> $vtn;
    (string)$game["vs"]-> $vs;
    (string)$game["d"]-> $d;
    (string)$game["t"]-> $t;
    }
    echo $hn;
if I use echo (string)... it outputs fine

I am trying to turn that long (string) into a variable that I can use much easier in html... as you can see I have tried the = and the -> but while I don't get any errors I also don't get any output either LOL

ANY help would be appreciated!!

Thank you!
Happy New Year! :D

Re: So far so good.. but need a bit of help

Posted: Fri Jan 02, 2015 4:05 pm
by Christopher
Do you have any idea what this code is doing?

Code: Select all

    (string)$game["htn"] = $htn;
    (string)$game["hs"]-> $hn;
    (string)$game["htn"]-> $vtn;
    (string)$game["vs"]-> $vs;
    (string)$game["d"]-> $d;
    (string)$game["t"]-> $t;
    }
    echo $hn;
It would be helpful if you provided a print_r() of $game and $hn so we know what the data in them actually is.