从json中提取链接

时间:2015-12-22 20:43:54

标签: php json

4天前Iam询问如何Extract the data from content of HTML

这是工作,一切都很好,但问题是打印所有数据,看起来像json:

{"post_id":"453298879","author_id":"1348","media_type":1,"images_src":"http:\/\/i.imgur.com\/JpfhVqK.png","content":"Hello World!"}

只想要images_src的内容。 http://i.imgur.com/JpfhVqK.png

我尝试使用 json_decode ,但无法正常工作。

Ps:没有json的文件,只是这个json的变量内容。

有什么想法吗?

2 个答案:

答案 0 :(得分:1)

var data =
   {"post_id":"453298879","author_id":"1348","media_type":1,"images_src":"http:\/\/i.imgur.com\/JpfhVqK.png","content":"Hello
    World!"};

的console.log(data.images_src)

data.image_src will output : 'http://i.imgur.com/JpfhVqK.png'

答案 1 :(得分:1)

有效:

$json = '{"post_id":"453298879","author_id":"1348","media_type":1,"images_src":"http:\/\/i.imgur.com\/JpfhVqK.png","content":"Hello World!"}';
$data = json_decode($json, true);
var_dump($data['images_src']);