So I am trying to grab something from another website via PHP and put the content into MYSQL. I get the data fine, but it's all out of order and can't think of a way to plug it into MYSQL.
Heres my code to get the data:
<?php
$i = 0;
$homepage = file_get_contents('http://linesfeed.com/nfl');
preg_match_all(
"'<td style=\'width:auto;color:#424241\' align=\'center\' valign=\'top\'>([^<]*)</td>'si",
$homepage, $match
);
foreach ($match[1] as $val) {
$i++;
$bracktextnumber = '<text' . $i . '>';
$bracktextnumberclose = '</text' . $i . '>';
echo $bracktextnumber . $val . $bracktextnumberclose . '<br>';
}
echo "End";
?>
Which outputs something like:
09.05.13
Ravens (Baltimore)
8.0 (-110)
+290
48.5o (-110)
8:35 PM
Broncos (Denver)
-8.0 (-110)
-350
48.5u (-110)
09.08.13
Patriots (NewEngland)
-11.5 (-110)
-630
48.5o (-110)
1:05 PM
Bills (Buffalo)
11.5 (-110)
+465
48.5u (-110)
So I want text1 (09.05.13) and text11 (09.08.13) to be entered as their own records as date in MYSQL. Text 2 (Ravens) and Text 6 (Broncos) to be added to the same entry as text 1, the Date. Text 12 and text 17 teams are added to the Text 11 dates record And so on.
Several things. The number of games loaded from this URL will vary, but the position will always remain the same. So like text 1 will always be a date, text 2 is always the first team...
Any help will be greatly appreciated! Specially if sample code is provided :)