Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(!defined("STDIN")) {
- define("STDIN", fopen('php://stdin','r'));
- }
- echo "Count Occurences of word in a file \n\n";
- $filename = 'st.txt';//(string) $_SERVER['argv'][1];
- echo "\n";
- $file = file($filename);
- $words = [];
- foreach($file as $line){
- $temp = explode(' ', $line);
- for($i = 0; $i < count($temp); $i++){
- array_push($words, iconv('UTF-8','ISO-8859-1//TRANSLIT',$temp[$i]));
- }
- }
- //var_dump($words);
- print_r(array_count_values($words));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement