php - 求正则循环匹配

查看:87
本文介绍了php - 求正则循环匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

 <dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbc8ups.html" target="_blank">20170408$http://www.iqiyi.com/v_19rrbc8ups.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbd47ic.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrbd47ic.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrnfp1nk.html" target="_blank">20170407$http://www.iqiyi.com/v_19rrnfp1nk.html</a></dd><dd class="iqiyi"><a href="http://www.iqiyi.com/v_19rrbcsn9g.html" target="_blank">20170406$http://www.iqiyi.com/v_19rrbcsn9g.html</a></dd>

我想要循环获得里面a标签里的value,如:
20170408$http://www.iqiyi.com/v_19rrbc...
20170407$http://www.iqiyi.com/v_19rrbd...

应该怎么写呢?

解决方案

preg_match_all('/(\d{8}\$[^<]+)/', $subject, $result, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($result[0]); $i++) {
    # Matched text = $result[0][$i];
}

这篇关于php - 求正则循环匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆