Re: use linux commands within php
| From: | daniel | Date: | Fri, 25 Jan 2002 20:28:08 +0000 |
| Subject: | Re: use linux commands within php | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-82161@lists.php.net to get a copy of this message | ||
> try this....
>
> <?
>
> system ("/usr/bin/wc -l $userfile> t.txt");
>
> $fd =fopen('t.txt', 'r');
> $buffer=fgets($fd,8);
>
> echo ($buffer);
> fclose($fd);
>
> ?>
Or... if you really just want to count the number of lines in a
file... do this:
<?
$ary = file("filename.txt");
print "There are " . count($ary) . " lines in filename.txt";
?>
This offers the advantage of having the file loaded into an array,
since... chances are you want to do something with it after you spit
out how many lines are in it.
Daniel J. Lashua