note 21978 modified in function.file by philip

From: Date: Sat, 01 Feb 2003 21:10:13 +0000
Subject: note 21978 modified in function.file by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-43275@lists.php.net to get a copy of this message
[[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... --was-- 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... http://www.php.net/manual/en/function.file.php

« previous php.notes (#43275) next »