使用php怎么返回字符串中的单词

这篇文章给大家介绍使用php怎么返回字符串中的单词,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。

代码如下: 

<?php
function split_en_str($str,$distinct=true) {
preg_match_all('/([a-zA-Z]+)/',$str,$match);
    if ($distinct == true) {
$match[1] = array_unique($match[1]);
    }
sort($match[1]);
    return $match[1];
}
?>

关于使用php怎么返回字符串中的单词就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。