Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从php中的内容获取链接_Php_Wordpress - Fatal编程技术网

如何从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]);