cowboysdude Posted January 15, 2011 Share Posted January 15, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/224482-cant-get-this-line-to-work/ Share on other sites More sharing options...
revraz Posted January 15, 2011 Share Posted January 15, 2011 Why do you have the . concantenate at the end? Quote Link to comment https://forums.phpfreaks.com/topic/224482-cant-get-this-line-to-work/#findComment-1159611 Share on other sites More sharing options...
cowboysdude Posted January 15, 2011 Author Share Posted January 15, 2011 Here's the entire code... because I'm not sure what your question means.. <?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... Quote Link to comment https://forums.phpfreaks.com/topic/224482-cant-get-this-line-to-work/#findComment-1159788 Share on other sites More sharing options...
Pikachu2000 Posted January 15, 2011 Share Posted January 15, 2011 echo "<div id='wrap'><div id='header'>" . implode("</div>", array_keys($sports)) . ; Get rid of: ^ this dot EDIT: Formatting fixed . . . Quote Link to comment https://forums.phpfreaks.com/topic/224482-cant-get-this-line-to-work/#findComment-1159789 Share on other sites More sharing options...
cowboysdude Posted January 15, 2011 Author Share Posted January 15, 2011 That got it!! OH Thank you so much!!!!! Quote Link to comment https://forums.phpfreaks.com/topic/224482-cant-get-this-line-to-work/#findComment-1159906 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.