Re: counting lines in a file?

From: Date: Tue, 26 Sep 2000 10:48:23 +0000
Subject: Re: counting lines in a file?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-17583@lists.php.net to get a copy of this message
Try: <html><body> <?php $org=exec("wc -l /etc/hosts"); $num=ereg_replace(" .*","", ereg_replace("^ *","", $org)); echo "\nnum=$num<br>\n"; ?> </body></html> hth, David. ----- Original Message ----- From: Michael Packer <pac@stingrayboats.com> To: <php-general@lists.php.net> Sent: Friday, September 22, 2000 6:26 PM Subject: [PHP] counting lines in a file? > I'm sure there is some slick way of doing this which is why i'm asking... > > what is the best way to count the number of lines in a file (ie wc -l > file.txt) in php > > currently i'm just going to open file, {read a line, inc counter} until EOF, > close file > > slick way??? > pac > 843 383 4507 x153 > Stingray Powerboats > http://StingrayBoats.com > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.general (#17583) next »