[php]
$url="http://www.nfl.com/liveupdate/scorestrip/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);
$find = array(
“ARI”,
“ATL”,
‘BAL’,
‘BUF’,
‘CAR’,
‘CHI’,
‘CIN’,
‘CLE’,
‘DAL’,
‘DEN’,
‘DET’,
‘GB’,
‘HOU’,
‘IND’,
‘JAC’,
‘KC’,
‘MIA’,
‘MIN’,
‘NE’,
‘NO’,
‘NYJ’,
‘NYG’,
‘OAK’,
‘PHI’,
‘PIT’,
‘STL’,
‘SD’,
‘SF’,
‘SEA’,
‘TAM’,
‘TEN’,
‘WAS’
);
$replace = array(
“Arizona Cardinals”,
“Atlanta Falcons”,
‘Baltimore Ravens’,
‘Buffalo Bills’,
‘Carolina Panthers’,
‘Chicago Bears’,
‘Cincinnati Bengals’,
‘Cleveland Browns’,
‘Dallas Cowboys’,
‘Denver Broncos’,
‘Detroit Lions’,
‘Green Bay Packers’,
‘Houston Texans’,
‘Indianapolis Colts’,
‘Jacksonville Jaguars’,
‘Kansas City Chiefs’,
‘Miami Dolphins’,
‘Minnesotta Vikings’,
‘New England Patriots’,
‘New Orleans Saints’,
‘New York Jets’,
‘New York Giants’,
‘Oakland Raiders’,
‘Philadelphia Eagles’,
‘Pittsburgh Steelers’,
‘Saint Louis Rams’,
‘San Diego Chargers’,
‘San Francisco 49ers’,
‘Seattle Seahawks’,
‘Tampa Bay Buccaneers’,
‘Tennessee Titans’,
‘Washington Redskins’
);
$games = array(
‘REG’ => array(),
‘WC’ => array(),
‘DIV’ => array(),
‘CON’ => array(),
‘PRO’ => array(),
‘SB’ => array()
);
foreach($xml->gms->g as $game) { // it’s a single game
// if (!empty($game[‘vtn’]))
{
$games[(string) $game['gt']][] = $game;
}
}
?>
<?php
foreach ($games as $gametype => $subgames) {
foreach ($subgames as $game) {
if ($game['gt'] == 'REG') {
$game = (str_replace($find, $replace, $game));
?>
[/php]
I added this and it returns nothing LOL
I believe that I have populated the $game variable then once I added this:
[php]
$game = (str_replace($find, $replace, $game)); [/php]
I believe I destroy that variable. What I’m trying to do is during the regular season the xml outputs team names like this DAL for Dallas Cowboys, NYG for New York Giants, etc…
SO when I’m showing the regular season games it just shows [example] - DAL 21 NYG 30
So I am trying to use the str_replace to replace the DAL with Dallas Cowboys…
Suggestions as to where I went wrong?
Thanks again.