I'm using the CakePHP 2.0 framework and I'm facing one problem. It's giving me the following error. I also used array_key_exists
.
: Undefined offset: 2 [APP/View/Doctors/admin_customize_plan_new.ctp, line 28]style="display:none"; id="checktab4">
I have two arrays. First is stored in $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
)
)
)
Second one is called $QuestionUserexists
Array
(
[0] => Array
(
[EveChfQuestionsUser] => Array
(
[cq_cp_id] => 1
)
)
[1] => Array
(
[EveChfQuestionsUser] => Array
(
[cq_cp_id] => 3
)
)
)
Now when I make a comparison between these two arrays, I'll get the error above.
My foreach loop is:
<?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>