This scrape returns:
- line 1:date
- line 2:home team
- line 3:score
- line 4:away team (same 4 elements repeated until the end)
I have tried everything to convert to an array, however no additions to this code have got the desired result, which would be something like a loop to give:
[1]date [2]home [3]score [4]away
etc.
until the end of doc.
<?php
$html = file_get_contents('http://www.soccerstats.com/round_details.asp?league=brazil'); //get the html returned from the following url
$doc = new DOMDocument();
libxml_use_internal_errors(TRUE);
if(!empty($html)){
$doc->loadHTML($html);
libxml_clear_errors(); //remove errors (html)
$xpath = new DOMXPath($doc);
$rows = $xpath->query('//b/font');
if($rows->length > 0){
foreach($rows as $row){
// $array[] = $row->nodeValue . "<br/>";
$array = $row->nodeValue . "<br/>";
print_r ($array);
}
}
}
?>
results:
1 Jun 14
 FluminenseÂ
1 - 1
 InternacionalÂ
1 Jun 14
 VitóriaÂ
0 - 1
 Sport RecifeÂ
1 Jun 14
 CorinthiansÂ
1 - 1
 BotafogoÂ
1 Jun 14
 ChapecoenseÂ
2 - 1
 BahiaÂ
1 Jun 14
 CruzeiroÂ
3 - 0
 FlamengoÂ
1 Jun 14
 SantosÂ
2 - 0
 CriciúmaÂ
1 Jun 14
 GrêmioÂ
0 - 0
 PalmeirasÂ
1 Jun 14
 FigueirenseÂ
1 - 3
 Atlético PRÂ
31 May 14
 São PauloÂ
2 - 1
 Atlético MGÂ
31 May 14
 CoritibaÂ
3 - 0
 GoiásÂ
30 May 14
 BahiaÂ
0 - 2
 SantosÂ
29 May 14
 InternacionalÂ
2 - 0
 ChapecoenseÂ
29 May 14
 FlamengoÂ
1 - 1
 FigueirenseÂ
29 May 14
 Atlético MGÂ
2 - 0
 FluminenseÂ
29 May 14
 Atlético PRÂ
2 - 2
 São PauloÂ
29 May 14
 CorinthiansÂ
1 - 0
 CruzeiroÂ
29 May 14
 GoiásÂ
0 - 0
 VitóriaÂ