Posted By

AzizLight on 02/11/10


Tagged


Versions (?)

Count the number of lines in a file


 / Published in: PHP
 

  1. /**
  2.  * Count number of lines in a file.
  3.  *
  4.  * @access private
  5.  * @param string filepath : The name of the file
  6.  * @return int : The number of lines
  7.  */
  8. private function _count_lines($file)
  9. {
  10. $handle = fopen( $filepath, "r" );
  11. $count = 0;
  12. while(fgets($handle))
  13. {
  14. $count++;
  15. }
  16. fclose($handle);
  17. return $count;
  18. } // End of _count_lines

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: linuxlover on June 21, 2013

The function fgets() takes 3 parameters.

You need to login to post a comment.