If I get post multiple word data, I want to split them and save it into db with different rows.
keyword = "apple,banana,orage,kiwi,mango"
so I wrote this code.
$keyword = $this->input->post('keyword');
$password = $this->input->post('pwd');
$password_confirm = 'password';
if($password == $password_confirm)
{
$ExplodeKeywords = explode(",", $keyword);
foreach($ExplodeKeywords as $val)
{
$arrayshift = array_shift($val);
if(count($arrayshift) > 0)
{
$query = 'INSERT INTO '.T_KEYWORD_POPULAR.' (kp_keyword, kp_time) VALUES ("'.$arrayshift.'", "'.date("Y-m-d H:i:s").'")';
$this->db->query($query);
}
}
echo 'GOOD!';
}
It doesn't save the foreach data into db.
Can you see what caused the problem?
array_shiftdoing there?$rowis not an array.