how to count the words in a specific string in PHP?

前端 未结 9 1553
忘了有多久
忘了有多久 2020-12-18 21:45

I want to count the words in a specific string , so I can validate it and prevent users to write more than 100 words for example .

I wrote this function but I don\'t

9条回答
  •  再見小時候
    2020-12-18 22:07

    Maybe str_word_count could help

    http://php.net/manual/en/function.str-word-count.php

    $Tag  = 'My Name is Gaurav'; 
    $word = str_word_count($Tag);
    echo $word;
    

提交回复
热议问题