我是PHP新手,请帮我解决这个问题。下面是编写的代码,后面是其结果。如何以最有效的方式访问count inside属性。代码
echo '<pre>';
print_r($result);
echo '</pre>';输出
Array
(
[0] => Array
(
[property] => Array
(
[href] => http://www.example.com
[count] => 2
[sample] => Array
(
)
[data] => Array
(
[0] => 100002067610524
[1] => 675985591
)
[users] =>
[active] => 1
)
)
)发布于 2011-03-21 14:35:42
不是最有效的,但是唯一可能的;-)
echo $result[0]['property']['count'];发布于 2011-03-21 14:35:53
如果您有多个元素,则使用以下代码
foreach($result as $childArray)
{
echo $childArray['property']['count'];
}如果只有一个元素,那么使用
$array = $result[0]['property']['count'];https://stackoverflow.com/questions/5374524
复制相似问题