The problem reduces to counting
\n characters, so is there a function that can do it on a huge strings, since explode() wastes too much memory.
substr_count should do the trick:
substr_count( $your_string, "\n" );
You can use PHP’s
substr_count() function: http://www.php.net/manual/en/function.substr-count.php
It will give you an integer with the number of occurrences.
i Think substr_count( $your_string, “\n” ); should be:
$numLine = substr_count( $your_string, "\n" ) +1;
But I use this:
$numLine = count(explode("\n",$your_string));
it always return correct result