Merge a multi-dimensional array to the custom array as required. Need the solution in PHP (using in Laravel-8). Custom array is needed to make rows for creating an excel file using Spreadsheet. This is the Original array I have =
array:3 [
0 => array:4 [
0 => array:3 [
0 => "Name"
1 => "English"
2 => "Math"
]
1 => array:3 [
0 => "John"
1 => 10
2 => 20
]
2 => array:3 [
0 => "Doe"
1 => 20
2 => 30
]
3 => array:3 [
0 => "Smith"
1 => 30
2 => 50
]
]
1 => array:4 [
0 => array:3 [
0 => "Name"
1 => "Science"
2 => "Hindi"
]
1 => array:3 [
0 => "John"
1 => 10
2 => 20
]
2 => array:3 [
0 => "Doe"
1 => 20
2 => 57
]
3 => array:3 [
0 => "Smith"
1 => 30
2 => 89
]
]
2 => array:4 [
0 => array:3 [
0 => "Name"
1 => "ABC"
2 => "XYZ"
]
1 => array:3 [
0 => "John"
1 => 10
2 => 20
]
2 => array:3 [
0 => "Doe"
1 => 20
2 => 23
]
3 => array:3 [
0 => "Smith"
1 => 30
2 => 89
]
]
]
From the above array need to make the array like below (array size may very, so need dynamic solutions) -
array:1 [
0 => array:4 [
0 => array:7 [
0 => "Name"
1 => "English"
2 => "Math"
3 => "Science"
4 => "Hindi"
5 => "ABC"
6 => "XYZ"
]
1 => array:7 [
0 => "John"
1 => 10
2 => 20
3 => 10
4 => 20
5 => 10
6 => 20
]
2 => array:7 [
0 => "Doe"
1 => 20
2 => 30
3 => 20
4 => 57
5 => 20
6 => 23
]
3 => array:7 [
0 => "Smith"
1 => 30
2 => 50
3 => 30
4 => 89
5 => 30
6 => 89
]
]
]
AssamesenorVaibhavnorFardeennorParthaappear to exist in your input data, so where are those coming from? Also, what have you tried so far, and what specifically was the problem with it? This site is not a code-writing service, so you should present an attempt at least.