Search
Syndication
Sponsors

Count Lines in a Text File

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)


This example counts the amount of lines in a text file, in this case we count the lines in the php.ini file on my system

<?php
//note the file below is for a windows machine
$testfile = “C:\\xampp\\apache\\bin\\php.ini”;
if (file_exists ($testfile))
{
$rows = file ($testfile);
echo count ($rows) . ” lines in this file”;
}
else
{
echo “Error, cannot open the file”;
}
?>

Related posts:

  1. Line Counter example This is a simple line counter example which will count...
  2. File list of a folder <?php //folder to check $folder = “C:/xampp/htdocs/xampp/wordpress/wp-includes”; $handle = opendir($folder);...
  3. create a gzip file this example backs up the index.php as a gzip file...
  4. FTP file upload example upload a single file to a FTP server // FTP...
  5. Percentage Of Similar Text Between 2 Strings This is a useful little fiunction you may not have...

Related posts brought to you by Yet Another Related Posts Plugin.



Tags: , ,

Leave a Reply