[英]Debugging Undefined Offset in CakePhp
我收到以下错误:
注意(8):未定义的偏移量:47 [APP / Template \\ CoursesEnrolled \\ view.ctp,第75行]
我已经尝试调试生产线,但是我该怎么办。
我的view.ctp看起来像这样:
$modulesEnrolled = Cake\Utility\Hash::combine($coursesEnrolled->courses_enrolled_modules,
'{n}.course_module_id','{n}');
// debug($modulesEnrolled);
$allModulesCompleted = true;
if (!empty($coursesEnrolled->course->course_modules)): ?>
<div class="">
<table class="table table-bordered table-hover" id="toggletable">
<thead>
<tr>
<th><?= __('Title') ?></th>
<th><?= __('Type') ?></th>
<th class="actions"><?= __('Actions') ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($coursesEnrolled->course->course_modules as $courseModules): ?>
<tr>
<td><?= h($courseModules->title) ?></td>
<td><?= h($courseModules->type) ?></td>
<td class="actions">
<?php
if($allModulesCompleted && $modulesEnrolled[$courseModules->id]['status'] == 'Pending') { //this is line 75
$allModulesCompleted = false;
}
任何帮助将不胜感激。
我的猜测是,您的一个数组不是从0开始。
$courseModules->id
与$modulesEnrolled
数组中的任何键都不匹配。
我会尝试增加或减少1,或者尝试以下操作:
$IDHere = (int)$courseModules->id - 1;
if($allModulesCompleted && $modulesEnrolled[$IDHere]['status'] == 'Pending') { //this is line 75
$allModulesCompleted = false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.