The New Source schrieb:
> How can I get a certain line from a file?
>
> If I get a file in this way:
>
> $f = fopen("http://www.url.com/index.htm","r");
>
> How can I get a certain line of the file index.htm?
>
> I would need to get the line number 232, or lines from 232 to 238. How can I get
>this content?
>
> Thanx.
>
> Rodrigo
>
<?php
...
$fromline=232;
$tillline=238;
$fp=fopen("http://www.url.com/index.htm", "r");
// go to line 232
fseek($fp, $fromline);
// how many lines to read ?
$numlines=$tillline-$fromline;
$i=0
// read the lines
while (!feof($fp) && $i<$numlines) {
$str[$i]=fgets($fp, $maxlength); // read line into Array
$i++; // next line
}
// now all lines from 232 till 238 are in the array $str[]
...
?>
--
@ Goetz Lohmann, Germany | Web-Developer & Sys-Admin
\/ ------------------------------------------------------
() He's the fellow that people wonder what he does and
|| why the company needs him, until he goes on vacation.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php