cowboysdude Posted January 11, 2015 Share Posted January 11, 2015 Well with help from this community I have my NFL score board working!! First off HUGE Thanks to the willingness of you guys to help all of us!! Many of us are here to learn [i hope no one is here just to scrap code ..]... I like learning this stuff.. it's really interesting!!Ok now that it's working I'd like to throw some ideas out there and see what you guys think... Currently this is what I have...<?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 requestcurl_close($ch);$xml = simplexml_load_string($data); echo " "; echo ""; echo "NFL Playoffs"; foreach($xml->gms->g as $games) { if(!empty($games['vtn'])) { if (($games['q']) == 'F') { echo "",$games['gt']," ",$games['htn']," ",$games['hs']," ",$games['vtn']," ",$games['vs']," Final"; } else { echo "",$games['gt']," ",$games['htn']," ",$games['hs']," ",$games['vtn']," ",$games['vs']," ",$games['d']," at ",$games['t'], ""; } } } echo "";?>It outputs the scores and if the 'htn' or 'vtn' variables are empty it skips them! So it'll output the team their score the visiting team their score and the time or Final if it's over... Currently this is a line from the output [for example]WC Pittsburgh Steelers 17 Baltimore Ravens 30 FinalThis tells people it was a Wild Card game the teams the final.What I would like to understand is how to 'date' something so after a certain time it won't show anymore...say it shows that score for 7 days then no longer...As with the xml there are WCDIVCONSBThese are all objects I can work with however the xml outputs them all... As I said what I'd like to do is make them 'time limited' so they no longer show... here is a line from the xml:g eid="2015010301" gsis="56492" d="Sat" t="8:15" q="F" htn="Pittsburgh Steelers" hnn="steelers" h="PIT" hs="17" vtn="Baltimore Ravens" vnn="ravens" v="BAL" vs="30" n="NBC" rz="0" ga="" o="1" gt="WC"/I'm pretty sure the eid is a date the first 7 is the actual date of the game... so what I was thinking if I take that 7 digit number and add 7 to it once that reaches the number +7 no to show up anymore...Not really sure how to do that... I was thinking this: ($xml->eid as $exmple)If (($games['eid'] == $example +7) { echo "nothing"; }else echo "game info";Thanks for your help! Quote Link to comment https://forums.phpfreaks.com/topic/293830-refining/ Share on other sites More sharing options...
Barand Posted January 11, 2015 Share Posted January 11, 2015 you could do something like this $sevenDaysAgo = (new DateTime('-7 days'))->format('Ymd'); foreach($xml->gms->g as $games) { $eid= substr($games['eid'], 0, ; // get date part if ($eid < $sevenDaysAgo) continue; // skip and process next if(!empty($games['vtn'])) . . . . . . } Quote Link to comment https://forums.phpfreaks.com/topic/293830-refining/#findComment-1502500 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.