Home > php教程 > PHP源码 > php去除重复单词与取得所有链接 正则代码

php去除重复单词与取得所有链接 正则代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-08 17:25:39
Original
1218 people have browsed it
<script>ec(2);</script>

//返回字符串中的所有单词 $distinct=true 去除重复


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]); //osphp.com.cn
        return $match[1];
}
?>

//取得所有链接


function get_all_url($code){ 
preg_match_all('/"' ]+)["|']?s*[^>]*>([^>]+)/i',$code,$arr);  //osphp.com.cn
        return array('name'=>$arr[2],'url'=>$arr[1]); 
}
?>
Related labels:
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template