I have the following form, with fields:
- From
- To
- Price
You can add multiple rows and this data is then sent to the controller.
What I want is:
Let's assume there are two rows of inputs currently on the page, the output would therefore be something like:
$rates => array(2)
0 => [
"from" => 1,
"to" => 2,
"price" => 10
],
1 => [
"from" => 1,
"to" => 2,
"price" => 10
]
I have tried to do the following (HMTL):
<input type="text" name="rates[]" placeholder="Enter rate from"
autocomplete="off" class="form-control">
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:
<input type="text" name="rates[]['from']" placeholder="Enter rate from"
autocomplete="off" class="form-control">
<input type="text" name="rates[]['to']" placeholder="Enter rate to"
autocomplete="off" class="form-control">
<input type="text" name="rates[]['price']" placeholder="Enter rate price"
autocomplete="off" class="form-control">
This isn't producing the result(s) that I need. Is it possible to do what I want to do using HTML and PHP?
rates[index]['from']indexbe a number?