我很难从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>";
任何人都可以请帮忙吗?对不起,这是如此基本。我一直在网上搜索,但找不到任何这方面的例子。
谢谢你这么多马里奥。将采取您的意见:) –