可以使用正则表达式来匹配。以下是一个示例代码:

<?php
$txt = '...'; // 假设 $txt 为原始字符串
$pattern = '/<a\s+href="([^"]+)"\s+class="play-btn\s+icon-btn">/i';
preg_match_all($pattern, $txt, $matches);
var_dump($matches[1]); // 输出匹配到的所有 href 链接
?>

解释一下上面的正则表达式:

  • <a\s+href=" 匹配 <a href=",其中 \s+ 表示至少一个空格或制表符。
  • ([^"]+) 匹配一个非空的字符串(不包含双引号),并将其保存在一个捕获组中。
  • \s+class="play-btn\s+icon-btn"> 匹配 class="play-btn icon-btn">,其中 \s+ 表示至少一个空格或制表符。

最终输出的结果是匹配到的所有 href 链接,保存在 $matches[1] 数组中。

$txt=div class=module-card-item module-itemdiv class=module-card-item-class电影diva href=voddetail339927html class=module-card-item-posterdiv class=module-item-coverdiv class=module-item-noteHD国语divdiv

原文地址: https://www.cveoy.top/t/topic/fzc9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录