标签:att pattern pat temp div func int order code
<?php $temp = ‘ <div class="num">1</div> <div class="num">2</div> <div class="num">3</div> <div class="num">4</div> <div class="num1">3</div> <div class="num2">4</div> <div class="num">5</div>‘; $result = get_tag_data($temp,"div","class","num"); print_r($result); 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];//返回值为数组 ,查找到的标签内的内容 }
标签:att pattern pat temp div func int order code
原文地址:https://www.cnblogs.com/f-rt/p/10848201.html