"Fred Atkinson" <fatkinson@mish mash.com> wrote in message
news:mvp0d01tk3 6m6ausqg698jav5 35o1p1329@4ax.c om...[color=blue]
> Is there a function that returns the number of lines in a text
> file? If so, what is it?
>
> Thanks,
>
>
>
> Fred
>[/color]
Pedro Graca wrote:
[color=blue]
> Fred Atkinson wrote:
>[color=green]
>> Is there a function that returns the number of lines in a text
>>file? If so, what is it?[/color]
>
>
> You have to read the file first.
>
> Either put the file contents in an array and count it:
>
> $lines = count($contents = file($file));
> // may leave ^^^^^^^^^^^^ this out!
>
>
> or put it in a string and count all the "\n"s
>
> $lines = substr_count($c ontents = file_get_conten ts($file), "\n");
> // may leave this out ^^^^^^^^^^^^[/color]
Not if it's a Mac ASCII file... ;) Then it's the "\r"s that you need to
count.
--
Justin Koivisto - spam@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.
*** Fred Atkinson wrote/escribió (Wed, 16 Jun 2004 15:34:18 GMT):[color=blue]
> Is there a function that returns the number of lines in a text
> file? If so, what is it?[/color]
Comment