php count lines in file – Efficiently counting the number of lines of a text file. This is a PHP function that will return the number lines in a text file. Use it to count lines in a data file.
php count lines in file
PHP – How to Calculate no of Lines in File?
index.php
PHP program to count the number of lines in a text file :
PHP Function to Count Lines in a Data Text File
Count lines a data text file
function isa_count_datafile_lines($file) { set_time_limit(300); ini_set('memory_limit', '-1'); $arr = file($file, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); $c = ( false === $arr) ? 0 : count($arr); set_time_limit(30);// restore to default ini_set('memory_limit','128M');// restore to default return $c; }
Example
$file = '/tmp/product_details.txt'; $count = isa_count_datafile_lines($file); echo 'There are ' . number_format($count) . ' lines in ' . $file;
I hope you get an idea about php count lines in file.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.