I have a form that allows multiple values for inputs
Car One
<input type="text" name="vehicle[]" placeholder="Enter Your Vehicle" />
Car Two
<input type="text" name="vehicle[]" placeholder="Enter Your Vehicle" />
When submitted it translates to an array like so
["vehicle"]=>
array(1) {
[0]=>
string(5) "Acura"
[1]=>
string(5) "Mazda"
}
["doors"]=>
array(1) {
[0]=>
string(6) "4 Door"
[1]=>
string(6) "2 Door"
}
I want to then translate this to individual arrays that are like so
[VehicleOne]=>
array(1) {
[vehicle]=>
string(5) "Acura"
[doors]=>
string(5) "4 door"
}
I have a custom function I created that does this but I am wondering if there are native php methods that can be used instead of multiple loops?
So this is what I am currently using. Not every $_POST value is an array so I have to check and if is then I divide them up.
foreach ($fields as $key => $row) {
if(is_array($row)){
foreach ($row as $column => $value) {
$doctors[$column][$key] = $value;
}
}
}