title: Laravel how to save data which in forloop
body: <p>I have data which I  need to save into database. Here's the example
  <a href="https://i.stack.imgur.com/0Vz3h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0Vz3h.png" alt="Example input"></a>
  Now my controller:</p>
  
  <pre><code>public function saveRequest(Request $request){
  
  $count = count($request-&gt;input('itemname'));
  $purchase = new PrRequest;
  
      for ($i=0; $i&lt;$count; $i++){
              $data[] = array(
              'pr_no' =&gt; $request-&gt;input('pr_no')[$i],    
              'pr_date' =&gt; $request-&gt;input('pr_date')[$i],
              'department' =&gt; $request-&gt;input('department')[$i],
              'remarks' =&gt; $request-&gt;input('remarks')[$i],
              'notes' =&gt; $request-&gt;input('notes')[$i],
              'requested_by' =&gt; $request-&gt;input('requested_by')[$i],
              'item_id' =&gt; $request-&gt;input('itemname')[$i],
              'qty' =&gt; $request-&gt;input('qty')[$i],
              'type' =&gt; $request-&gt;input('type')[$i],
              'uom' =&gt; $request-&gt;input('uom'),
              'pd_date' =&gt; $request-&gt;input('pd_date')[$i]
              );
          $purchase-&gt;fill($data[$i])-&gt;save(); 
      }
      return Response::json($data, 200, array(), JSON_PRETTY_PRINT);
  }
  </code></pre>
  
  <p>I got error after clicking save button.</p>
  
  <pre><code>ErrorException in helpers.php line 671:
  preg_replace(): Parameter mismatch, pattern is a string while replacement is an array
  </code></pre>
  
  <p>Any solution? Thank you in advance.</p>