Little help to get this thing home...

Well I"m learning on the fly here but am stumped…

This is what I have so far:

[php]<?php

include_once “helper.php”;

$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 $games)

{
echo “

”;
echo $games[‘htn’]," VS “,$games[‘vtn’],” on “,$games[‘d’],” at ",$games[‘t’];
echo “
”;

}

?>[/php]

It’s working well problem is too well… is that possible? LOL

Yeah it’s returning things like this:

Pittsburgh Steelers VS Baltimore Ravens on Sat at 8:15

Which is great however it’s also returning things like this:

New England Patriots VS on Jan 10 at 4:35

and

VS on Jan 18 at 3:05

which I don’t want… I know I need to check for empty objects and NOT echo those but am really stumped here.

Help would be greatly appreciated!!

Thank you all! ;D

[php]<?php

include_once “helper.php”;

$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 $games)

{
if(!empty($games[‘vtn’]))
{
echo “

”;
echo $games[‘htn’]," VS “,$games[‘vtn’],” on “,$games[‘d’],” at ",$games[‘t’];
echo “
”;
}
}

?>[/php]

That’s the one!!! THANK YOU!!! Been driving myself nuts trying every combination… it’s always something I totally overlook!

Trying to learn this but it’s been slow and painful LOL!!!

Thank you again!!! :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service