RE: [PHP] counting lines in a file?
| From: | Unknown Sender | Date: | Wed, 27 Sep 2000 13:45:53 +0000 |
| Subject: | RE: [PHP] counting lines in a file? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-17690@lists.php.net to get a copy of this message | ||
If you have PHP version 3.0.16 or better:
<?
$my_file = file(myfile.txt);
$total_lines = count($my_file);
?>
--
Gene Stevens |
----------------------------| "Quid quid Latine
gene@triplenexus.org | dictum sit,
http://gene.triplenexus.org | altum viditur."
-----Original Message-----
From: David Newcomb [mailto:davidn@vnvi.com]
Sent: Tuesday, September 26, 2000 5:48 AM
To: Michael Packer; php-general@lists.php.net
Subject: Re: [PHP] counting lines in a file?
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.