This article describes the way php reads a text file and prints out the most characters and the number of times the row is used. Share to everyone for your reference, specific as follows:
Test.txt file:
Welcome to our website jb51.net
www.jb51.net
php asp java JSP
PHP code (read Test.txt file):
$myfile = fopen ("Test.txt", "R");
while (!feof ($myfile)) {
$line _str = fgets ($myfile);
$str _arr = Count_chars ($line _str, 1);
Arsort ($str _arr);
Print_r (Key ($str _arr)). "Is". Current ($str _arr). PHP_EOL);
}
Fclose ($myfile);
The results of the operation are as follows:
For more information on PHP related content readers can view the site topics: "Summary of PHP file operations", "PHP string (String) Usage summary", "PHP common traversal algorithm and skills summary", "PHP Regular Expression Usage summary", "PHP operation and operator Usage Summary", " Introduction to PHP Basic Grammar, "Introduction to PHP object-oriented Programming", "PHP+MYSQL Database Operations Introduction Tutorial" and "PHP Common database Operation tips Summary"
I hope this article will help you with the PHP program design.