Home >php教程 >PHP源码 >返回字符串中的所有单词

返回字符串中的所有单词

PHP中文网
PHP中文网Original
2016-05-25 17:14:311282browse

//返回字符串中的所有单词 $distinct=true 去除重复 
<? 
function split_en_str($str,$distinct=true) { 
preg_match_all(&#39;/([a-zA-Z]+)/&#39;,$str,$match);
//开源代码OSPHP.COM.Cn
        if ($distinct == true) { 
$match[1] = array_unique($match[1]); 
        } 
sort($match[1]); //OSPHP.COm.CN 
        return $match[1]; 
} 
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn