If the lines terminate in "\n", I'd use fgets($fp,1000) in a loop, and loop
as many times as needed.

$fp=fopen("filename","r") or die ("couldn't open filename");
for ($count=1;$count<=10,$count++)
    {
    $line=fgets($fp,1000);   // the 1000 represents the number of bytes to
go to unless it finds "\n" sooner.
    print "$line";
    }
I'm prety sure the above will work.
Hugh
----- Original Message -----
From: Jon Farmer <[EMAIL PROTECTED]>
To: Tauntz <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, August 28, 2001 6:40 AM
Subject: RE: [PHP] How do I read the first n lines from a file?


> If you are on a unix box you might want to use the tail command... if you
> use exec() the output will be in an array...
>
> --
> Jon Farmer  Õ?Õ?
> Systems Programmer, Entanet www.enta.net
> Tel +44 (0)1952 428969 Mob +44 (0)7968 524175
> PGP Key available, send blank email to [EMAIL PROTECTED]
>
> -----Original Message-----
> From: Tauntz [mailto:[EMAIL PROTECTED]]
> Sent: 28 August 2001 12:13
> To: [EMAIL PROTECTED]
> Subject: [PHP] How do I read the first n lines from a file?
>
>
> hi !
>
> I have a simmple question :)..
>
> Lets say that I have a file called:
> list.txt
> and I want to take the first 10 lines from it & echo it to the browser ?
>
> thank you
> [EMAIL PROTECTED]
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to