title: PHP Laravel - HTML Forms array of values
body: <p>I have the following form, with fields: </p>
  
  <ul>
  <li>From </li>
  <li>To </li>
  <li>Price</li>
  </ul>
  
  <p>You can add multiple rows and this data is then sent to the controller. </p>
  
  <p>What I want is:</p>
  
  <p>Let's assume there are two rows of inputs currently on the page, the output would therefore be something like:</p>
  
  <pre><code>$rates =&gt; array(2)
     0 =&gt; [ 
        "from" =&gt; 1, 
        "to"   =&gt; 2,
        "price" =&gt; 10
     ], 
     1 =&gt; [ 
        "from" =&gt; 1, 
        "to"   =&gt; 2,
        "price" =&gt; 10
     ]   
  </code></pre>
  
  <p>I have tried to do the following (HMTL):</p>
  
  <pre><code>  &lt;input type="text" name="rates[]" placeholder="Enter rate from" 
    autocomplete="off" class="form-control"&gt;
  </code></pre>
  
  <p>But this just gives me an array of 6 with all the values, with no way of knowing the order. I have also tried the following:</p>
  
  <pre><code>&lt;input type="text" name="rates[]['from']" placeholder="Enter rate from" 
        autocomplete="off" class="form-control"&gt;
  
   &lt;input type="text" name="rates[]['to']" placeholder="Enter rate to" 
        autocomplete="off" class="form-control"&gt;
  
   &lt;input type="text" name="rates[]['price']" placeholder="Enter rate price" 
        autocomplete="off" class="form-control"&gt;
  </code></pre>
  
  <p>This isn't producing the result(s) that I need. Is it possible to do what I want to do using HTML and PHP?</p>