Split sentence into words

后端 未结 3 1705
我寻月下人不归
我寻月下人不归 2021-01-16 15:25

for example i have sentenes like this:

$text = \"word, word w.d. word!..\";

I need array like this

Array
(
    [0] => w         


        
3条回答
  •  自闭症患者
    2021-01-16 16:03

    use

    str_word_count ( string $string [, int $format = 0 [, string $charlist ]] )
    

    see here http://php.net/manual/en/function.str-word-count.php it does exactly what you want. So in your case :

    $myarray = str_word_count ($text,1);
    

提交回复
热议问题