2012-01-07 23 views
0

我是一個PHP noob ... 無論如何 - 我如何獲得這個字符串的所有圖像鏈接? (到一個數組)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

BTW我已經從一個腳本標籤刮掉上面的數據...

在此先感謝

回答

4

那麼,你可以使用正則表達式爲。但是,因爲它似乎是JSON,所以可以簡單地致電json_decode()

如果您需要數組結構,請將第二個參數設置爲TRUE
然後訪問它想:

print $array["imagedata"]["images"]["image1"]["url"]; 
+0

好極了!作爲noob我不會注意json的東西:) – knalle 2012-01-07 02:13:03

相關問題