Возникает такая ошибка Undefined offset: 6 в ряду
$item = $changeOnUnsubscribed->selected_checkbox[$i];
Как ее решить?
$changeOnUnsubscribed = new ContactList();
if ($changeOnUnsubscribed->load(Yii::$app->request->post())) {
$contactId = ContactList::find()->where(['contact_id' => $id])->all();
foreach ($contactId as $id) {
$count = count($changeOnUnsubscribed->selected_checkbox);
for ($i = 0; $i <= $count; $i++) {
$item = $changeOnUnsubscribed->selected_checkbox[$i];
if ($item != 0) {
if ($item == $id->id) {
$changeOnUnsubscribed->status = 0;
$changeOnUnsubscribed->save();
}
}
}
}
}