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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
cowboysdude
Forum Newbie
Posts: 5
Joined: Sun Jan 11, 2009 6:22 pm

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

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

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

Post 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.
(#10850)
Post Reply