试图阻止循环覆盖以前存储的值

I have a form where a user can can select which role has access to which form i.e:

---------canView canAdd canEdit canDelete

form1 chkbox chkbox chkbox chkbox

form2 chkbox chkbox chkbox chkbox

When using check boxes, I noticed only the ones that are checked get their values sent when I post the form.So I decided to send the value of each form ID in each check box.

When I submit my form, I have my check box values sent in an array. For each checked check box, I submit an ID value that will be used to insert into a database. Below is my code:

<input type="checkbox" name="chkCanView[]" value="<?php echo $fId;?>"/>
<input type="checkbox" name="chkCanAdd[]" value="<?php echo $fId;?>"/>
<input type="checkbox" name="chkCanEdit[]" value="<?php echo $fId;?>"/>
<input type="checkbox" name="chkCanDelete[]" value="<?php echo $fId;?>"/>

$canView = $this->input->post('chkCanView');
$canAdd = $this->input->post('chkCanAdd');
$canEdit = $this->input->post('chkCanEdit');
$canDelete = $this->input->post('chkCanDelete');

for($i = 0; $i < count($forms); $i++)
        {
            $curForm = $forms[$i];
            for($j = 0; $j < count($forms); $j++)
            {
                $curView[$j] = (($canView[$j] == $curForm)?1:0);
                $curAdd[$j] = (($canAdd[$j] == $curForm)?1:0);
                $curEdit[$j] = (($canEdit[$j] == $curForm)?1:0);
                $curDelete[$j] = (($canDelete[$j] == $curForm)?1:0);
            }//for              
        }//for
//insert into DB
for($c = 0; $c < count($forms); $c++)
        {               
            $curForm = $forms[$c];
            $data= $this->db->query("select formAccessLevelKey from          FormAccessLevel where formId = $curForm")->row();
            $formKey = $data->formAccessLevelKey;           
            if(empty($formKey))
            {
                $this->db->query("uspFormAccessLevelCRUD NULL, $curForm, $roleId, $curView[$c], $curAdd[$c], $curEdit[$c], $curDelete[$c], '$sessionId', 'NULL' ,0");   
            }
            else
            {
                $this->db->query("uspFormAccessLevelCRUD '$formKey', $curForm, $roleId, $curView[$c],$curAdd[$c], $curEdit[$c], $curDelete[$c], 'NULL', '$sessionId',0");
            }
        }//for  

What I want to do is get the check box's id value and compare it with the current form ID. If its the same then I save 1 as the variable to be passed to the database. If its not the same I save 0

It seems like every time I go through the outer for loop it overwrites the values previously saved. I want to be able to skip if there is already 1 stored at the index being checked.

use a

if (value == true) {
continue
}

if the value exist then continue that means jump over it without doing anything