<div class="container">
<label>Service Offering</label></br>
<?php
$new_array=array('1'=>'Engineering and Design','2'=>'Operations and support','3'=>'Product management','4'=>'Developer relations and technical solutions','5'=>'Sales and account management','6'=>'Partnerships','7'=>'Sales and operations','8'=>'Administrative services','9'=>'Business strategy planning','10'=>'Finance solutions','11'=>'Legal and government relations','12'=>'Marketing and communications','13'=>'Real estate and workplace services','14'=>'Social impact solutions','15'=>'Consultancy services','16'=>'Investors and funding');
if(isset($new_array))
$services = array_column($services,'service_offered');
foreach($new_array as $key=>$val):
if($db_key = array_search($val,$services))
{ ?>
<input type="checkbox" name='service[]' value="<?php echo $key ?>" checked ><?php echo $val; ?> <br/>
<?php }
else
{
?>
<input type="checkbox" name='service[]' value="<?php echo $key ?>" ><?php echo $val; ?><br/>
<?php }
endforeach; ?>
</div>
In this view file $services is fetched from another controller file as an object and then converted to array here so as to process the data in systematic way..........but here the problem i am facing is whenever i check multiple boxes suppose 3,,,,,the first in the list which is checked doest show up checked but the others show up......more cleary explaining....suppose $services has service1,service2 and service3................when i check these three boxes and click on update button it stores all the three services in database table but only service2 and service3 are being shown as checked.plz help me..i did print_r and checked the value of var and service both exactly matching then too service1 goes to else part