2013-12-16 17 views
1

我在下面的數據格式,我認爲這爲j的兒子,我想呼應其形象,但JSON解碼不工作就可以了,請幫我整合我的編碼到WordPress平臺無法在WordPress數組中轉換json數據?

 
a:5:{s:4:"name";s:36:"e4da3b7fbbce2345d7772b0674a318d5.jpg";s:4:"type";s:10:"image/jpeg";s:5:"error";i:0;s:4:"size";i:2795;s:10:"thumb_name";s:42:"e4da3b7fbbce2345d7772b0674a318d5_thumb.jpg";} 

回答

2

您需要使用unserialize()將數據轉換爲其原始形式:

$data = 'a:5:{s:4:"name";s:36:"e4da3b7fbbce2345d7772b0674a318d5.jpg";s:4:"type";s:10:"image/jpeg";s:5:"error";i:0;s:4:"size";i:2795;s:10:"thumb_name";s:42:"e4da3b7fbbce2345d7772b0674a318d5_thumb.jpg";}'; 
$decoded = unserialize($data); 
// then you should be able to get the path to the image 
print $decoded['name']; 
+1

太感謝你了 – user3051901

+0

@ user3051901 - 沒問題,只是很高興我能幫助=) – Cyclonecode