RE: [PHP] How do I read the first n lines from a file?

From: Date: Tue, 28 Aug 2001 12:30:09 +0000
Subject: RE: [PHP] How do I read the first n lines from a file?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-64772@lists.php.net to get a copy of this message
Oops.. Forgot to close the file. Put as last line: fclose($fp); Niklas -----Original Message----- From: Niklas Lampén [mailto:niklas.lampen@publico.fi] Sent: 28. elokuuta 2001 15:29 To: Tauntz; Php-General Subject: RE: [PHP] How do I read the first n lines from a file? You can do this: $i = 0; $fp = fopen("list.txt", "r"); while (!feof($fp) && $i < 10) { $i++; $Text = fgets($fp, 4096); // Reads first 4096 characters from a row. print "$Text<br>\n"; }; Niklas -----Original Message----- From: Tauntz [mailto:tauntz@hot.ee] Sent: 28. elokuuta 2001 14:13 To: php-general@lists.php.net 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 Tauntz@hot.ee

« previous php.general (#64772) next »