1.
function get_tag_data($html,$tag,$class,$value){
//$value 为空,则获取class=$class的所有内容
$regex = $value ? "/<$tag.*?$class=\"$value\".*?>(.*?)<\/$tag>/is" : "/<$tag.*?$class=\".*?$value.*?\".*?>(.*?)<\/$tag>/is";
preg_match_all($regex,$html,$matches,PREG_PATTERN_ORDER);
return $matches[1];//返回值为数组 ,查找到的标签内的内容
}
$a = get_tag_data($s,"a","id","xiaoqu");本文为看恩吧原创文章,转载无需和我联系,但请注明来自knsay.com