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

返回字符串中的所有单词

PHP中文网
Release: 2016-05-25 17:14:31
Original
1272 people have browsed it

//返回字符串中的所有单词 $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]; 
} 
?>
Copy after login

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template