PHP, explode multiple words and insert into DB table
<p>If I get post multiple word data, I want to split them and save it into db with different rows.</p>

<pre><code> keyword = "apple,banana,orage,kiwi,mango"
</code></pre>

<p>so I wrote this code.</p>

<pre><code>$keyword = $this-&gt;input-&gt;post('keyword');
$password = $this-&gt;input-&gt;post('pwd');
$password_confirm = 'password';

if($password == $password_confirm)
{
    $ExplodeKeywords = explode(",", $keyword);

    foreach($ExplodeKeywords as $val) 
    {
        $arrayshift = array_shift($val);
        if(count($arrayshift) &gt; 0)
        {
            $query = 'INSERT INTO '.T_KEYWORD_POPULAR.' (kp_keyword, kp_time) VALUES ("'.$arrayshift.'", "'.date("Y-m-d H:i:s").'")';
            $this-&gt;db-&gt;query($query);               
        }
    }

    echo 'GOOD!';
}
</code></pre>

<p>It doesn't save the foreach data into db.</p>

<p>Can you see what caused the problem?</p>
