preg_match_all返回false。
$str ="<h1 class="page-title" id="page-title-heading" aria-labelledby="page-title-heading toolbar-amount" > <span class="base" data-ui-id="page-title-wrapper" >Sarees</span> </h1>";
$king = preg_match('/<h1>(.*?)<\/h1>/s', $str, $matches);
if ($king) {
echo $matches[0];
}else{
echo "false";
}
答案 0 :(得分:0)
添加&#34;除了>
&#34;考虑可能的属性:
$king = preg_match('/<h1[^>]*>(.*?)<\/h1>/s', $str, $matches);
^^^^^