Count Lines in a Text File
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:
- Line Counter example This is a simple line counter example which will count...
- File list of a folder <?php //folder to check $folder = “C:/xampp/htdocs/xampp/wordpress/wp-includes”; $handle = opendir($folder);...
- create a gzip file this example backs up the index.php as a gzip file...
- FTP file upload example upload a single file to a FTP server // FTP...
- 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: count, File, file_exists



















