Array
(
[0] => stdClass Object
(
[href] => http://www.google.com
[description] => search
[extended] =>
[meta] => x
[hash] => x
[time] => 2013-04-09T02:00:57Z
[shared] => yes
[toread] => no
[tags] =>
)
[1] => stdClass Object
(
[href] => http://shop.frankchimero.com/collections/frontpage/products/the-shape-of-design-digital-preorder
[description] =>
[extended] =>
[meta] => x
[hash] => x
[time] => 2013-04-06T19:39:51Z
[shared] => yes
[toread] => no
[tags] =>
)
我有一个这样的数组,但我不知道如何解析它。我该怎么做,“foreach 0,1,2,3等获得href”?
答案 0 :(得分:2)
使用json_decode
选项TRUE将结果集作为数组返回,然后遍历数组。
$data = json_decode($my_array, TRUE);
foreach($data as $info) {
echo $info['href'];
echo $info['time'];
//etc..
}
答案 1 :(得分:0)
你可以做到
foreach($yourJSONArrayName as $jsonObject)
{
echo $jsonObject->href; //etc
//print_r($jsonObject);
}
答案 2 :(得分:0)
foreach ($jsonPages as $page)
{
var_dump($page->href);
}