> Hvor meget kode skal der til?
Her er det kode, jeg har skrevet for at hente holdnavnene til denne uges
Tips 13 og Tips 12 ved tipstjenesten:
function tips_get_data() {
$url_page13 = "
http://www.tips.dk/spil/tips/tips13/ugens_tips13.html";
$url_page12 = "
http://www.tips.dk/spil/tips/tips12/ugens_tips12.html";
/* Retrieving Tips-13 */
$page13 = fopen($url_page13, "r");
$i = 1;
while (!feof($page13)) {
$line[$i] = fgets($page13);
$i++;
}
$k = 61;
$offsets = array(61, 18, 18, 20, 18, 18, 20, 18, 18, 20, 18, 18, 18);
$cnt = 0;
for ($g=0; $g<13; $g++) {
$cnt = $cnt + $offsets[$g];
$matches[$g+1] = $line[$cnt];
}
/* Uge hentes */
$uge13 = $line[42];
$dato13 = $line[25];
/* Retrieving Tips-12*/
$page12 = fopen($url_page12, "r");
$i = 1;
while (!feof($page12)) {
$line[$i] = fgets($page12);
$i++;
}
$k = 61;
$offsets = array(61, 18, 18, 20, 18, 18, 20, 18, 18, 20, 18, 18);
$cnt = 0;
for ($g; $g<25; $g++) {
$cnt = $cnt + $offsets[$g-13];
$matches[$g+1] = $line[$cnt];
}
/* Uge hentes */
$uge12 = $line[42];
$dato12 = $line[25];
/* Automatist opdeling af holdene i de 25 kampe */
$i=1;
for ($i=1; $i<26; $i++) {
$notags = strip_tags($matches[$i]);
$trimmed = trim($notags);
$teams = explode("-", $trimmed);
$sides[$i][0] = trim($teams[0]);
$sides[$i][1] = trim($teams[1]);
}
$temp = $uge12;
$uge12 = strip_tags($temp);
$uge12 = trim($uge12);
$temp = $uge13;
$uge13 = strip_tags($temp);
$uge13 = trim($uge13);
$temp = $dato13;
$dato13 = strip_tags($temp);
$dato13 = trim($dato13);
$temp = $dato12;
$dato12 = strip_tags($temp);
$dato12 = trim($dato12);
$sides[26][0] = $uge13;
$sides[26][1] = $dato13;
$sides[27][0] = $uge12;
$sides[27][1] = $dato12;
return $sides;
} /* function */