title: saving multidimensional array as rows in mysql using laravel 5
body: <p>i have a multidimensional array from a form that looks like this:</p>
  
  <pre><code>  $items =  array:8 [▼
    "units" =&gt; array:4 [▼
      0 =&gt; "1"
      1 =&gt; "1"
      2 =&gt; "1"
      3 =&gt; "1"
    ]
    "article_group" =&gt; array:4 [▼
      0 =&gt; "2401"
      1 =&gt; "2503"
      2 =&gt; "1360"
      3 =&gt; "1198"
    ]
    "article" =&gt; array:4 [▶]
    "description_en" =&gt; array:4 [▶]
    "unit_price" =&gt; array:4 [▶]
    "discount" =&gt; array:4 [▶]
    "invoice" =&gt; array:4 [▶]
    "delivery_note" =&gt; array:4 [▶]
  ]
  </code></pre>
  
  <p>The form is dynamically generated, and will not always contain 4 values, but they will always contain the same amount of values.</p>
  
  <p>What i want to do is to save these records in a mysql database like this:</p>
  
  <pre><code>$bookingDetails = new bookingDetails;
  $bookingDetails-&gt;units = units[0];
  $bookingDetails-&gt;article_group = article_group[0];
  $bookingDetails-&gt;article = article[0];
  $bookingDetails-&gt;description_en = description_en[0];
  $bookingDetails-&gt;unit_price = unit_price[0];
  ...
  $bookingDetails-&gt;save();
  
  and then the same thing with [1] and [2] and so on.
  </code></pre>
  
  <p>but how do i iterate through this in that way? </p>
  
  <p>Regards Johan</p>