note 21978 deleted from function.file by felipe

From: Date: Mon, 10 Dec 2007 18:20:16 +0000
Subject: note 21978 deleted from function.file by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-133272@lists.php.net to get a copy of this message
Note Submitter: e dot maccarthy at csuohio dot edu ---- [[Editors note: using fopen/fgets instead of file() would be more efficient for this task as there is no need to load the entire file into memory]] Here is a quick snippet that will read in N number of lines of a file, then print them. $n=10 $fp = file('/path/to/your/file'); $i=0 while($i < $n){ echo "$fp[$i]"; $i++; } I am using this right now to display the current progress of the seti@home client working on my server, instead of displaying the whole thing, which isn't web page friendly. Because sometimes short really is sweet...

« previous php.notes (#133272) next »