我使用CakePHP 2.0框架,我遇到了一个问题。它给了我以下错误。我还使用了array_key_exists
。
: Undefined offset: 2 [APP/View/Doctors/admin_customize_plan_new.ctp, line 28]style="display:none"; id="checktab4">
我有两个数组。首先存储在$carePlansList
:
Array
(
[0] => Array
(
[EveCarePlansList] => Array
(
[id] => 1
[care_plan_name] => CHF
)
)
[1] => Array
(
[EveCarePlansList] => Array
(
[id] => 3
[care_plan_name] => Hypertension
)
)
[2] => Array
(
[EveCarePlansList] => Array
(
[id] => 4
[care_plan_name] => ABC
)
)
)
第二个名为$QuestionUserexists
Array
(
[0] => Array
(
[EveChfQuestionsUser] => Array
(
[cq_cp_id] => 1
)
)
[1] => Array
(
[EveChfQuestionsUser] => Array
(
[cq_cp_id] => 3
)
)
)
现在当我在这两个数组之间进行比较时,我会得到上面的错误。
我的foreach循环是:
<?php
foreach ($carePlansList as $key => $plansList) { ?>
<li role="presentation" class="planLists"
<?php if($QuestionUserexists[$key]['EveChfQuestionsUser']['cq_cp_id'] == $plansList['EveCarePlansList']['id'] ){
}else{?>
style="display:none";
<?php } ?>>
</li>