I've figured this out now, it should at least explain what i want to do. But it doesn't work.
?php
$filename = "foo.txt";
$inline = file($filename);
$lines = count($inline);
for ($x = 0; $x < $lines; $x++) {
echo("$x<br>\n");
if ($inline[$x] == "begin") {
$data = 1;
} elseif ($inline[$x] == "end") {
$data = 0;
}
if ($data == 1) {
echo ("$inline[$x]<br>\n");
}
}
?>