Hi,
I've a big file, and I want to count the number of lines.
I tried this:
$i=0;
$fp =fopen('file',' r');
while ( ! feof ($fp) ) {
$ligne = fgets($fp,8096) ;
$i++;
}
and this:
$i = exec("wc -l file");
The first solution is slower, but the second isn't cross system.
How can I do fast and clean ?
Thanks.
I've a big file, and I want to count the number of lines.
I tried this:
$i=0;
$fp =fopen('file',' r');
while ( ! feof ($fp) ) {
$ligne = fgets($fp,8096) ;
$i++;
}
and this:
$i = exec("wc -l file");
The first solution is slower, but the second isn't cross system.
How can I do fast and clean ?
Thanks.
Comment