Answer the question
In order to leave comments, you need to log in
Editing a multidimensional array?
Good night everybody. The second day I struggle with the task.
There is a dynamic form
Fields are added dynamically, for clarity below I have indicated a diagram of a possible form
${id} - $cinema->id
<form method="POST">
@foreach($cinemas as $cinema)
Кинотеатр
@foreach(сеансы)
<input type="text" name="cinema[${id}][date_start][]">
<input type="text" name="cinema[${id}][price][]">
@endforeach
@endforeach
<input type="submit">
</form>
0 => [
'cinema_id' => 24,
'date_start' => 0,
'price' => 100,
],
1 => [
'cinema_id' => 23,
'date_start' => 0,
'price' => 150,
],
2 => [
'cinema_id' => 23,
'date_start' => 0,
'price' => 140,
]
Answer the question
In order to leave comments, you need to log in
$cinemas = $request->cinema;
$cinemas = collect($cinemas)->map(function($item, $key){
$item['cinema_id'] = $key;
return $item;
})->toArray();
dd($cinemas);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question