I have post function that is an array in itself, the post contains full names of people in the form of an array such as:
Array(
[0] => Adda Gweno
[1] => Tom malombo
)
I would like to go through this array and explode the values of each key using the space as a delimiter so I can send the individual values to a separate array to be stored separately.
What I have so far:
function save_drs() {
$Surname = $this->input->post('Surname');
foreach ($Surname as $e_name):
$individual = explode(" ", $e_name);
endforeach;
$Suggested_Salary = $this->input->post('Suggested_Salary');
for ($i = 0; $i < count($Surname); $i++) {
$bio = array(
'Surname' =>$individual[0][$i],
'Other_Names' => $individual[1][$i],
'Suggested_Salary'=>$Suggested_Salary[$i]
);
// $this->db->insert('main_table', $bio);
print_r($bio);
}
}
This prints the first letters of the names instead of the words
Array
(
[Surname] => A //Should be Adda
[Other_Names] => G //Should be Gweno
)
Array
(
[Surname] => T //Should be Tom
[Other_Names] => M //Should be Malombo
)
Suggestions?