php去除重复单词与取得所有链接 正则代码
//返回字符串中的所有单词 $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(http://pic3.phprm.com/2011/01/22/$code.jpg){ preg_match_all('/<as+href=["|']?([^>"' ]+)["|']?s*[^>]*>([^>]+)</a>/i',$code,$arr); //osphp.com.cn return array('name'=>$arr[2],'url'=>$arr[1]); }
永久链接:http://www.phprm.com/code/37096.html
转载随意!带上文章地址吧。