Checking checkbox value for serialized mysql data PHP

one text

Currently I have a permissions page where there are checkboxes for each user role. Now I'm passing these values as a serialized array when the form is submitted making it so that all checked values show as true and unchecked values show as N:

example: a:35:{s:5:"leads";s:4:"true";s:9:"all_leads";N;s:10:"unassigned";N;s:6:"active";s:4:"true";...

Now I want to show the true values as checked in my view class which I'm not sure how to do.

Currently this is my code:

View Class:

      <tr>
        <td class="align-center">1</td>
        <td>Leads</td>
        <td>leads/lists</td>
        <?php foreach($roles as $rolekey => $role){ ?>
          <td align="center"><div class="checkbox checkbox-success m-t-0"><input type="checkbox" value="true" class="accessbox" id="role<?php echo $rolekey ?>" name="leads"  /><label for="role<?php echo $rolekey ?>"></label></div></td>
        <?php } ?>
      </tr>
      <tr>
        <td class="align-center">2</td>
        <td>All Leads</td>
        <td>leads/lists/all</td>
        <?php foreach($roles as $rolekey => $role){?>
        <td align="center"><div class="checkbox checkbox-success m-t-0"><input type="checkbox" value="true" class="accessbox" id="role<?php echo $rolekey ?>" name="all_leads"  /><label for="role<?php echo $rolekey ?>"></label></div></td>
        <?php } ?>
      </tr>

Controller Class:

$arrayPermissionsInsert = array();
$arrayPermissionsInsert['leads'] = $this->input->post('leads'); 
$arrayPermissionsInsert['all_leads'] = $this->input->post('all_leads'); 
$datatable=array('permissions'=> serialize($arrayPermissionsInsert));
$loginid = $this->users_model->set_permissions($id,$datatable);

Now I just need to find a way to unserialize this array and mark it as checked if the value is true in the serialized array.

The following is the response on var_dumping $roles:

array(1) { [0]=> array(6) { ["roles_id"]=> string(1) "4" 
["role"]=> string(5) "Admin" ["status"]=> string(1) "Y" ["can_manage"]=> string(1) "0"
["permissions"]=> string(632) "a:35:{s:5:"leads";N;s:9:"all_leads";s:4:"true";s:10:"unassigned";
s:4:"true";s:6:"active";N;s:3:"hot";N;s:6:"closed";N;
s:10:"transacted";N;s:4:"pool";N;s:8:"calendar";N;s:8:"contacts";N;
s:5:"buyer";N;s:10:"leadagents";N;}" ["can_manage_role"]=> NULL } }

Source