cowboysdude Posted October 5, 2011 Share Posted October 5, 2011 Currently I am using this very popular code to get all the football scores: $title = $params->get('title'); $fontc = $params->get('fontc'); $fonts = $params->get('fonts'); //this array contains sports and their URLs $sports = array( "NFL" => "http://sports.espn.go.com/nfl/bottomline/scores"); $results = array(); foreach ( $sports as $sport => $url ) { //get the page pointed to by $url $page = file_get_contents($url); //grab all variables out of the page preg_match_all("/&([^=]+)=([^&]+)/", urldecode($page), $foo); //loop through all the variables on the page foreach ( $foo[1] as $key => $value ) { //debug output, you can delete this next line //echo "{$value} = {$foo[2][$key]}\t<br />\n"; //this chain of IF/elseif statements is used to determine which pattern to use //to strip out the correct data, since each sport seems to have its own format //for the variables you'd "want" if ( $sport == "NFL" && preg_match("/s_left\d+/", $value) ) { $results[$sport][] = $foo[2][$key]; } } } //calculate the sport with the most number of rows $limit = 0; foreach ( $results as $countMe ) { $limit = max($limit, count($countMe)); } //spit out the table with the right headers echo "<td><b> $title </b></td><br><BR>"; "<table border=4 cellpadding=10><tr><th>" . implode("</th><th>", array_keys($sports)). "</th></tr>" ; //loop until you reach the max number of rows, printing out all the table rows you want for ( $p = 0; $p < $limit; $p++ ) { foreach ( array_keys($sports) as $sport );{ $change = str_replace('^','<font color=green><b>W</b> </font>' ,$results[$sport][$p]); $final = str_replace('(FINAL)','<font color=red>(FINAL)', $change); echo "<td><font color=$fonts size=$fontc><b>$final</b></font></td><br>"; } echo "</tr>"; } //kill the table echo "</table>"; and it works fantastically well however.... I'd only like to get certain data say like the Cowboys game info and nothing more... NOT too sure how to do this, I'm just not really sure how to read the page, grab only that data. Help would be greatly appreciated! Thank you. Quote Link to comment https://forums.phpfreaks.com/topic/248451-php-and-grabbing-only-certain-data/ Share on other sites More sharing options...
Pikachu2000 Posted October 5, 2011 Share Posted October 5, 2011 Wouldn't it be easier to just assume Romo had another meltdown and they lost? Quote Link to comment https://forums.phpfreaks.com/topic/248451-php-and-grabbing-only-certain-data/#findComment-1275869 Share on other sites More sharing options...
cowboysdude Posted October 5, 2011 Author Share Posted October 5, 2011 Welllllllllllllllllllllllll LOL THAT is just funny!!!!!!!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/248451-php-and-grabbing-only-certain-data/#findComment-1275875 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.