Okay, what I am tryin to archive here, is to grab live football scores from eurosport.com website. I would like to state, that my knowlage of coding is absoloutley 0. This code was developed by my friend: function getScore() { $data = file_get_contents('http://eurosport.yahoo.com/'); $result = ''; preg_match_all('/<div.+?id="ep-livemod-live">.+?<table class="football".+?summary=".+? \- Live Now".+?>(.+?)<\/table>.+?<\/div>/sm', $data, $data); $newData = ''; $count = count($data[1]); for ($i = 0; $i < $count; ++$i) { $newData .= $data[1][$i]; } $data = $newData; preg_match_all('/<span class="home">(.+?)<\\/span>/', $data, $teamOne); preg_match_all('/<span class="score">(.+?)<\\/span>/', $data, $score); preg_match_all('/<span class="away">(.+?)<\\/span>/', $data, $teamTwo); $count = count($score[1]); if ($count == 0) { return 'There are currently no live events taking place.'; } for ($i = 0; $i < $count; ++$i) { if (!isset($teamOne[1][$i]) || !isset($score[1][$i]) || !isset($teamTwo[1][$i])) { continue; } $teamOne = $teamOne[1][$i]; $teamTwo = $teamTwo[1][$i]; $team1s = str_split($teamOne); $team2s = str_split($teamTwo); $teamOne = ""; $teamTwo = ""; $a = 0; while($a <= 8) { $teamOne = $teamOne."".$team1s[$a]; $a++; } $a = 0; while($a <= 8) { $teamTwo = $teamTwo."".$team2s[$a]; $a++; } $teamOne = $teamOne.".."; $teamTwo = $teamTwo.".."; $result .= $teamOne.' '.$score[1][$i].' '.$teamTwo.'<br />'; } return $result; } getScore(); Code (markup): It works, but it has one problem: There are two games being showd on eurosport.com atm as you can see on the picture. But on my website, it only shows one (the first one) game: (don't mind the text writen on the pictures ) How do I make it show all the games going on at eurosport.com?
Try this, however I'm not to sure about how you have the results echoing out to your page, the results using the below code will echo one line for both matches. function getScore() { $data = file_get_contents('http://eurosport.yahoo.com/'); $result = ''; preg_match_all('/<div.+?id="ep-livemod-live">.+?<table class="football".+?summary=".+? \- Live Now".+?>(.+?)<\/table>.+?<\/div>/sm', $data, $data); $newData = ''; $count = count($data[1]); for ($i = 0; $i < $count; ++$i) { $newData .= $data[1][$i]; } $data = $newData; preg_match_all ('/<span class="home">(.+?)<\\/span>/isU', $data, $teamOne); preg_match_all ('/<span class="score">(.+?)<\\/span>/isU', $data, $score); preg_match_all ('/<span class="away">(.+?)<\\/span>/isU', $data, $teamTwo); $count = count($score[1]); if ($count == 0) { return 'There are currently no live events taking place.'; } for ($i = 0; $i < $count; ++$i) { if (!isset($teamOne[1][$i]) || !isset($score[1][$i]) || !isset($teamTwo[1][$i])) { continue; } $teamOne = $teamOne[1][$i]; $teamTwo = $teamTwo[1][$i]; $team1s = str_split($teamOne); $team2s = str_split($teamTwo); $teamOne = ""; $teamTwo = ""; $a = 0; while($a <= 8) { $teamOne = $teamOne."".$team1s[$a]; $a++; } $a = 0; while($a <= 8) { $teamTwo = $teamTwo."".$team2s[$a]; $a++; } $teamOne = $teamOne.".."; $teamTwo = $teamTwo.".."; $result .= $teamOne.' '.$score[1][$i].' '.$teamTwo.'<br />'; } return strip_tags($result); } //echo getScore() getScore(); PHP: