我很難從Json數組中檢索值。我有一個使用json_encode創建的Json數據集。這是怎麼出現使用json_decode並顯示使用print_r的經過:從Json數組中檢索值
Array ([0] => stdClass Object ([postID] => 1961 [postTitle] => Kiss My Fairy [previewThumb] => 2011/09/Kiss-My-Fairy-Ibiza-essentialibiza-2011_feature.jpg [blogContent] => Ibiza has always had a flair for the extravagant, inhibitions are checked in at the airport when the floods of tourists arrive and the locals have embraced a freedom of partying that has turned the quiet Mediterranean island into the Mecca...)) a_post_data_array = 1
是實現這一功能的代碼如下:
$post_data_URL = "http://myurl.com/news/scrape/facebook-like-chart-ID.php?post_name=kiss-my-fairy";
$post_data_response = file_get_contents($post_data_URL);
$a_post_data_array=json_decode($post_data_response);
我現在只是需要從該數組檢索一些值用作變量。該數組將只有一組值。我正在使用下面的代碼,但它不起作用。
echo "**** -- " . $a_post_data_array[post_title] . "<br>";
任何人都可以請幫忙嗎?對不起,這是如此基本。我一直在網上搜索,但找不到任何這方面的例子。
謝謝你這麼多馬里奧。將採取您的意見:) –