0

我是一个 PHP 菜鸟......无论如何 - 我如何从这个字符串中获取所有图像链接?(成一个数组)

{                      "imagedata": {       "duration": 4000,       "images":{                "image1":{         "url":"/images/nature/flowers/pictureKUO133529A.jpeg",         "title":"",         "index":"01"         },         "image2":{         "url":"/images/nature/flowers/pic092533.jpg",         "title":"",         "index":"02"         },         "image3":{         "url":"/images/nature/flowers/pic092529.jpg",         "title":"",         "index":"03"         },         "image4":{         "url":"/images/nature/flowers/pic092531.jpg",         "title":"",         "index":"04"         },         "image5":{         "url":"/images/nature/flowers/pic092530.jpg",         "title":"",         "index":"05"         },         "image6":{         "url":"/images/nature/flowers/pic092534.jpg",         "title":"",         "index":"06"         },         "image7":{         "url":"/images/nature/flowers/0112678pic092532.jpg",         "title":"",         "index":"07"         },         "image8":{         "url":"/images/nature/flowers/0112881pic092656.jpg",         "title":"",         "index":"08"         },         "image9":{         "url":"/images/nature/flowers/0112880pic092655.jpg",         "title":"",         "index":"09"         }       }       }                     }

我已经尝试过使用 preg_match_all() 但我无法让它工作....我只想要像 /images/nature/flowers/0112880pic092655.jpg 这样的字符串

顺便说一句,我已经从脚本标签中抓取了上述数据......

提前致谢

4

1 回答 1

4

好吧,您可以为此使用正则表达式。但由于它似乎是 JSON,一个简单的调用就json_decode()可以了。

TRUE如果需要数组结构,请将第二个参数设置为。
然后像这样访问它:

print $array["imagedata"]["images"]["image1"]["url"];
于 2012-01-07T01:01:56.167 回答