简体   繁体   English

在PHP数组中解析值

[英]parsing values in a php array

I am new to PHP, please help me with the stuff. 我是PHP的新手,请帮助我。 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
                        (
                            [0] => 100002067610524
                            [1] => 675985591
                        )

                    [users] => 
                    [active] => 1
                )

        )

)

不是最有效的,而是唯一可能的;-)

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'];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM