title: CodeIgniter : How to receive serialize post data in array on RESTful Server?
body: <p>i want to ask, how to receive data from serialize data in array on CodeIgniter RESTful Server ?</p>
  
  <p><strong>Ajax</strong></p>
  
  <pre><code>$.ajax({
      type: 'POST',
      url: "/mywebsite/api/index.php/purchase",
      data: $("#formdatatrans").serialize(),
      success: function(response) {
          alert("Success");
      }
  });
  </code></pre>
  
  <p><strong>Html Form</strong></p>
  
  <pre><code>&lt;input type="text" name="data1[]"&gt;
  &lt;input type="text" name="data2[]"&gt;
  &lt;input type="text" name="data3[]"&gt;
  &lt;input type="text" name="data4[]"&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>function index_post() {       
  $data = array(
              'data1'           =&gt; $this-&gt;post('data1'),
              'data2'       =&gt; $this-&gt;post('data2'),
              'data3'             =&gt; $this-&gt;post('data3'),
              'data4'    =&gt; $this-&gt;post('data4'));
  $insert = $this-&gt;db-&gt;insert('table1', $data);
  if ($insert) {
  $this-&gt;response($data, 200);
  } else {
  $this-&gt;response(array('status' =&gt; 'fail', 502));
  }}
  </code></pre>
  
  <p><strong>Input Data</strong></p>
  
  <pre><code>Array [0]
  Data1 = abc_1
  Data2 = abc_1
  Data3 = abc_1
  Data4 = abc_1
  
  Array [1]
  Data1 = abc_2
  Data2 = abc_2
  Data3 = abc_2
  Data4 = abc_2
  </code></pre>
  
  <p>How to add all of the data above in one time using for / while looping ?</p>
  
  <p>Thanks in advance</p>