- $myfile = fopen("test.txt", "r");
- while(!feof($myfile)) {
- $line_str = fgets($myfile);
- $str_arr = count_chars($line_str, 1);
- arsort($str_arr);
- print_r(chr(key($str_arr)).' is '.current($str_arr).PHP_EOL);
- }
- fclose($myfile);
来源: https://www.oschina.net/code/snippet_175116_58812