私はCodeigniterを使用してデータベースに複数フォーム入力データを挿入しています。 私はこのポストの入力配列を持っている:Codeigniterバッチ配列を挿入
Array
(
[subject_id] => Array
(
[0] => 1
[1] => 1
)
[question] => Array
(
[0] => test
[1] => test2
)
[option1] => Array
(
[0] => test
[1] => test2
))
私はどのように私はこの配列が挿入バッチを使用して、この配列を挿入するためにどのように挿入するように変換しないことを得ることはありません。
$this->db->insert_batch('mytable', $data);
これは私がデータを投稿するために使用フォームコードです:
以下 <form method="post">
<input type="text" name="subject_id[]" >
<input type="text" name="question[]" >
<input type="text" name="record[]" >
// Down side Part is appended when user want to add more question
<input type="text" name="subject_id[]" >
<input type="text" name="question[]" >
<input type="text" name="record[]" >
<input type="submit" name="submit" >
</form>
は、私が欲しいアレイ形式です。
$data = array(
array(
'subject_id' => 'My title' ,
'question' => 'My Name' ,
'option1' => 'My date'
),
array(
'subject_id' => 'Another title' ,
'question' => 'Another Name' ,
'option1' => 'Another date'
)
);
どのようにあなたは、この配列を得るのですかに関するあなたの質問であなたのコードを投稿しますか? –
先生質問を更新しました。 @dhruvjadia –
もう一度質問を更新しました。結果の配列に必要なものを追加しました。 @dhruvjadia –