Hey guys, all right?
I have a problem with a project I'm developing. I get a form where the user informs the data but in this form, it is possible that it clicks a button to insert new inputs and inform other data.
The array I am using as a test is this: (But it can vary as the user enters other fields.)
array:8 [▼
"name" => array:3 [▼
0 => "101"
1 => "102"
2 => "103"
]
"gate" => array:3 [▼
0 => "1"
1 => "1"
2 => "1"
]
"chairs_initial" => array:3 [▼
0 => "80"
1 => "161"
2 => "242"
]
"chairs_final" => array:3 [▼
0 => "160"
1 => "241"
2 => "322"
]
"tickets_avaliable" => array:3 [▼
0 => "80"
1 => "80"
2 => "80"
]
"price_full" => array:3 [▼
0 => "40"
1 => "40"
2 => "40"
]
"price_half" => array:3 [▼
0 => "20"
1 => "20"
2 => "20"
]
"plant_sector" => array:3 [▼
0 => UploadedFile {#291 ▶}
1 => UploadedFile {#303 ▶}
2 => UploadedFile {#287 ▶}
]
]
And in it I travel as follows:
<?php
foreach ($temp_sectors as $i => $temp) {
foreach ($temp as $j => $val) {
$sec[$j] = $val;
dd($sec);
}
}
And I always have the return of the first position of 'name' like this:
0 => "101"
No access to 'gate', 'chairs_initial', 'chairs_final' ... I do not know if there is another way, but what I would like to put together is to separate this data by position in a temporary array, for example:
array:0 [▼
"name" => "101"
"gate" => "1"
"chairs_initial" => "80"
...
]
array:1 [▼
"name" => "102"
"gate" => "1"
"chairs_initial" => "161"
...
]
array:2 [▼
"name" => "103"
"gate" => "1"
"chairs_initial" => "242"
...
]
For me to be able to after that perform a foreach on this temporary array and insert the data into my database. I do not know if there is another simpler form, but if there is one I would like to understand it.
Thanks in advance!