print_r($result) 得到如下内容stdClass Object ( [results] => Array ( [0] => stdClass Object ( [topicsource] => 1212 [updatedAt] => 2015-03-08T00:32:05.185Z [topictitle] => 1212 [objectId] => 54fb9885e4b0e89e0edc15e1 [topiccontent] => fdsafdsaf [createdAt] => 2015-03-08T00:32:05.185Z [topicsummary] => dsafafds [screenshot] => [createdby] => 3 ) [1] => stdClass Object ( [topicsource] => fdsafdsa [updatedAt] => 2015-03-08T00:32:32.951Z [topictitle] => dfasfdsa [objectId] => 54fb98a0e4b0e89e0edc16e0 [topiccontent] => fdsafdsafdsaf [createdAt] => 2015-03-08T00:32:32.951Z [topicsummary] => fdsafdsaf [screenshot] => [createdby] => 3 ) [2] => stdClass Object ( [topicsource] => fdsafdsa [updatedAt] => 2015-03-08T00:32:54.475Z [topictitle] => fdsafd [objectId] => 54fb98b6e4b0e89e0edc17b0 [topiccontent] => fdasfdasfdsaf [createdAt] => 2015-03-08T00:32:54.475Z [topicsummary] => fdsafds [screenshot] => [createdby] => 3 ) [3] => stdClass Object ( [topicsource] => 测试来源 [updatedAt] => 2015-03-08T01:08:05.494Z [topictitle] => 我来测试 [objectId] => 54fba0f5e4b0e89e0edc7617 [topiccontent] => 具体简介 [createdAt] => 2015-03-08T01:08:05.494Z [topicsummary] => 具体内容 [screenshot] => stdClass Object ( [name] => [email protected] [type] => image/png [tmp_name] => /tmp/phpYYpzYw [error] => 0 [size] => 4646 ) [createdby] => 3 ) [4] => stdClass Object ( [createdby] => 3 [topicsummary] => 具体内容 [createdAt] => 2015-03-08T01:09:30.161Z [topiccontent] => 具体简介 [objectId] => 54fba14ae4b0e89e0edc79a7 [topictitle] => 我来测试 [updatedAt] => 2015-03-08T01:09:30.161Z [topicsource] => 测试来源 ) ) )一共是五条信息,用echo count($result),结果却是 1,不是5, 通过下面代码想历遍,却得不到结果$num = count($return);
for($i=0;$i<$num;++$i){
echo $return[$i].'<br />';
} 请问如何得到正确的内容?
for($i=0;$i<$num;++$i){
echo $return[$i].'<br />';
} 请问如何得到正确的内容?
echo $item->topicsource . '<br />';
echo $item->updatedAt . '<br />';
echo $item->topictitle . '<br />';
echo $item->objectId . '<br />';
echo $item->topiccontent . '<br />';
echo $item->createdAt . '<br />';
}
估計你是json_decode而來的,
json_decode($data, true); 就會輸出數組了。