How should I do this: I want to read some specific lines from the file. This reads all of the text in file and works ok:
$file = fopen ("http://www.mol.fi/Tietoa/Ammatti/00/3/0/1/30110.html", "r");
while (!feof ($file)) {
$teksti = fgets($file, 255);
echo $teksti;
}
fclose ($file);
But when I try to read only some of the text, this doesn't work. What's wrong?
$file = fopen ("http://www.mol.fi/Tietoa/Ammatti/00/3/0/1/30110.html", "r");
while (!feof ($file)) {
$teksti = fgets($file, 255);
//there are links inside the page
$start = '<A NAME="työtehtävät">';
$end = '<A NAME="kelpoisuusehdot">';
$start_position = strpos($teksti, $start);
$end_position = strpos($teksti, $end)+strlen($end);
$length = $end_position-$start_position;
$teksti = substr($teksti, $start_position, $length);
echo $teksti;
}
fclose ($file);
Thanks if you can help me.