Count how often the word occurs in the text in PHP

后端 未结 4 586
说谎
说谎 2020-12-18 01:44

In php I need to Load a file and get all of the words and echo the word and the number of times each word shows up in the text, (I also need them to show up in descending or

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-18 02:25

    $words = str_word_count($text, 1);
    $word_frequencies = array_count_values($words);
    arsort($word_frequencies);
    print_r($word_frequencies);
    

提交回复
热议问题