求教各位大神,我用正则取href后面链接,试了很久都没有试出来

我的小鱼干呢 2019-03-14 11:28:39
<div class="jin-flash_icon">
<a target="_blank" href="//view.jin10.com/news20190312181454391200.html"><i class="jin-icon jin-icon_flashNews"></i></a>
</div>
...全文
53 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
床上等您 2019-03-14
  • 打赏
  • 举报
回复

<?php

$str=<<<STR
<div class="jin-flash_icon">
<a target="_blank" href="//view.jin10.com/news20190312181454391200.html"><i class="jin-icon jin-icon_flashNews"></i></a>
</div>
STR;

preg_match_all('#href="(.*?)"#', $str, $matches);
var_dump($matches);

array(2) {
[0]=>
array(1) {
[0]=>
string(53) "href="//view.jin10.com/news20190312181454391200.html""
}
[1]=>
array(1) {
[0]=>
string(46) "//view.jin10.com/news20190312181454391200.html"
}
}

21,887

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧