如何从php中的内容获取链接
我创建了一个帖子,里面有一个我想要得到链接的锚定标签 形成帖子内容。存储在数据库中的数据如下:-如何从php中的内容获取链接,php,wordpress,Php,Wordpress,我创建了一个帖子,里面有一个我想要得到链接的锚定标签 形成帖子内容。存储在数据库中的数据如下:- <a href="https://www.manresa-sj.com/wp-content/uploads/2017/02/PhotoOfSteve.png">all data is here for you</a> WP_Post Object ( [post_content] => all data is here for you ) 我想从Po
<a href="https://www.manresa-sj.com/wp-content/uploads/2017/02/PhotoOfSteve.png">all data is here for you</a>
WP_Post Object
(
[post_content] => all data is here for you
)
我想从Post_内容链接https://www.manresa-sj.com/wp-content/uploads/2017/02/PhotoOfSteve.png
是否可能?如果您的意思是要从文本中提取图像链接。 使用正则表达式
$string = '<a href="https://www.manresa-sj.com/wp-content/uploads/2017/02/PhotoOfSteve.png">all data is here for you</a>';
$pattern = '~(http.*\.)(jpe?g|png|[tg]iff?|svg)~i';
$m = preg_match_all($pattern,$string,$matches);
print_r($matches[0]);