Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/238.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 访问特定的数组()元素_Php_Arrays_Cakephp_Foreach - Fatal编程技术网

Php 访问特定的数组()元素

Php 访问特定的数组()元素,php,arrays,cakephp,foreach,Php,Arrays,Cakephp,Foreach,我的调试($planDetails)输出如下。为什么我不能以如下标准方式访问数组元素: foreach ($planDetails as $planRow) : echo $planRow['Plan']['Applicant']['name']; endforeach; 我得到未定义的索引:计划错误 我也尝试过:echo$planlow['Plan']['name'] Array ( [PlanDetail] => Array (

我的调试($planDetails)输出如下。为什么我不能以如下标准方式访问数组元素:

    foreach ($planDetails as $planRow) :
        echo $planRow['Plan']['Applicant']['name'];
    endforeach;
我得到未定义的索引:计划错误

我也尝试过:echo$planlow['Plan']['name']

Array
(
[PlanDetail] => Array
        (
            [id] => 54
            [name] => BasicOne
        )


[Plan] => Array
        (
            [0] => Array
                (
                    [id] => 255
                    [monthly_cost] => 20.23
                    [age_id] => 14
                    [applicant_id] => 8
                    [plan_detail_id] => 54
                    [Age] => Array
                        (
                            [id] => 14
                            [name] => 18-64
                        )

                    [Applicant] => Array
                        (
                            [id] => 8
                            [name] => Subscriber +2
                        )
               )
    [2] => Array
               (
                   [id] => 254
                   [monthly_cost] => 15.50
                   [age_id] => 14
                      [applicant_id] => 27
                [plan_detail_id] => 54
                   [Age] => Array
                       (
                           [id] => 14
                           [name] => 18-64
                       )

                   [Applicant] => Array
                       (
                           [id] => 27
                           [name] => Subscriber + 1
                       )

               )
)

阵列中缺少一个级别。你想要

$planRow['Plan'][0]['Applicant']['name'];

阵列中缺少一个级别。你想要

$planRow['Plan'][0]['Applicant']['name'];

哼!谢谢我会接受你的回答,当时间限制超过(约8分钟)。呸!谢谢我会接受你的答复,当时间限制(约8分钟)结束。