Jump to content

can't get this line to work...


cowboysdude

Recommended Posts

echo "<div id='wrap'><div id='header'>" . implode("</div>", array_keys($sports)) . ; 

 

I get the following error:

 

Parse error: syntax error, unexpected ';' in /hermes/bosweb/xxxxx/xxx/xxxxxxxxxxxxxxxx/xxxxx/xxx_xxxx/xxx_xxxxxx.php on line 75

 

The above line is 75.  I have changed the quotes using ' ' or " " and no matter what I do I continue to get errors.. where am I going wrong here? 

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/224482-cant-get-this-line-to-work/
Share on other sites

Here's the entire code...  because I'm not sure what your question means..  :D

 

<?php 
//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 "<div id='wrap'><div id='header'>" . implode("</div>", array_keys($sports)) . ; 
//loop until you reach the max number of rows, printing out all the table rows you want 
for ( $p = 0; $p < $limit; $p++ ) { 
  echo "<tr>"; 
  foreach ( array_keys($sports) as $sport ) { 
    echo "<td>{$results[$sport][$p]}</td>"; 
  } 
  echo "</tr>"; 
} 
//kill the table 
echo "</table></div>"; 

 

 

Line 75 is the output... If there's a better way to do it I"m all ears LOL  I just find it hard to believe I can't get that line to work...

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.