parsing values in a php array
I am new to PHP, please help me with the stuff. Below is the code written followed by its results. How can i access [count] inside [property] in most effective way. code
echo '<pre>';
print_r($result);
echo '</pre>';
output
Array
(
[0] => Array
(
[property] => Array
(
[href] => http://www.example.com
[count] => 2
[sample] => Array
(
)
[data] => Array
(
开发者_C百科 [0] => 100002067610524
[1] => 675985591
)
[users] =>
[active] => 1
)
)
)
Not the most effective, but the only possible ;-)
echo $result[0]['property']['count'];
if you have more than one element then use this
foreach($result as $childArray)
{
echo $childArray['property']['count'];
}
if you have only one element in it then use
$array = $result[0]['property']['count'];
精彩评论