I have an array like below.
$permis =array(
'employee' => array(
'myprofile' => array(
'default' => '0', 'personal' => '0', 'job' => '0', 'leave' => '0', 'permission' => '0', 'bonus & commision' => '0', 'document' => '0', 'emergency contact' => '0', 'benifits' => '0'
),
'viewallemployee' => array(
'default' => '0', 'personal' => '0', 'job' => '0', 'leave' => '0', 'permission' => '0', 'bonus & commision' => '0', 'document' => '0', 'emergency contact' => '0', 'benifits' => '0', 'notes' => '0', 'onboard' => '0', 'offboard' => '0', 'charts' => '0'
)
)
);
i am using for each in to this array and get the output like below :
<?php
foreach($permis as $key => $myprofile){
$module = $key;
foreach($myprofile as $key => $profile){
$submodule = $key;
foreach($profile as $key => $data){
?>
<td><?php echo $module; ?></td>
<td><?php echo $submodule; ?></td>
<td><?php echo $key; ?></td>
<td>
<?php echo $submodule.$key; ?>
<select name="<?php $submodule.$key; ?>">
<option value='<?php $data ?>'><?php echo $data; ?></option>
<option value='1'>1</option>
<option value='2'>2</option>
</select>
</td>
</tr>
<?php
}
}
}
?>
My question is i want to store my select option values into my mysql database tabel with arrayname and keyname example
myprofile default 0 myprofile personal 0 etc.
How to do this. please anyone help me
you can use json_encode to convert array into string and then you can store in database. OR you can use serialize() to convert array into storable format in Mysql.
Try this:
json_encode($permis); // Can be stored in Database
OR this:
serialize($permis); // Can be stored in Database