
==========
<?php
$test =<<<EOF
<a class="t4" href="read.php?id=9576" title="ffff">********</a>
@@@@@@@@@@@@@@
<a class="t5" href="read.php?id=9576" title="ffff">@@@@@@@</a>
EOF
$pattern = '/href="(.*?)"/'
preg_match_all($pattern,$test,$result)
//你要的结果在数组的第二个元素内.
//print_r($result)
foreach($result[1] as $ritem){
echo $ritem
}
?>
preg_replace正则匹配,去除所有a链接地址,并且保留里面a里面的内容preg_replace(“#<a[^>]*>(.*?)</a>#is”, “$1”,$body)
ereg_replace正则匹配:
ereg_replace(“]*>|</a>”,””,$content)
ereg_replace函数匹配以”<a “开头,中间除>以外的所有字符,再以>结尾的字符串或匹配””字符。匹配到的字符串赋为空。
preg_match_all('/<a[^>]+href="([^"]+)"[^>]+class="green"[^>]+/Ui', $str, $arr)
print_r($arr[1])
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)