Re: Appending to a file

From: Date: Thu, 11 Jul 2002 10:36:11 +0000
Subject: Re: Appending to a file
Groups: php.general 
Request: Send a blank email to php-general+get-107090@lists.php.net to get a copy of this message
>I'm just curious if there's a function that allows you to see how many lines >there are in a file. I could just set up a while(!feof($fp)) { fgets($fp); >count++; } obviously, but I'm curious if there's a function built in like >"flines($fp)" that I haven't noticed at php.net? If it's a relatively small file, it might be a little faster to do: <?php $file = file("filename.txt" or die("Could not open file"); echo count($file); ?> It will suck the whole file into an array of lines faster than you can do fgets() in PHP. -- Like Music? http://l-i-e.com/artists.htm Off-Topic: What is the moral equivalent of 'cat' in Windows?

« previous php.general (#107090) next »