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

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

WBOY
WBOYOriginal
2016-06-08 17:25:391167browse
<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]); 
}
?>
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
Previous article:迅雷地址正则匹配代码Next article:php无限创建目录