检索链接值形式< a href>使用PHP标记 [英] Retrieve The link value form <a href> tag using php

查看:70
本文介绍了检索链接值形式< a href>使用PHP标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用php代码提取存储在<a href>标记中的链接值.

I need to extract the link value which is stored in a <a href>tag by using php code.

<a href="http://stackoverflow.com/questions/ask"></a>

从上面的代码中,我想使用php代码提取链接http://stackoverflow.com/questions/ask.

From the above code i want to extract the link http://stackoverflow.com/questions/ask using php code.

推荐答案

$url = '<a title="Question" href="http://stackoverflow.com/questions/ask"></a>';
preg_match("/href=\"(.*?)\"/i", $url, $matches);
print_r($matches);
/*
Match Group(s) :
        1.  http://stackoverflow.com/questions/ask
*/

这篇关于检索链接值形式&lt; a href&gt;使用PHP标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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