I have two arrays with the following structure
array
'main' => array
'firstYearStudents' => array
0 => '10'
1 => '12'
'secondYearStudents' => array
0 => '8'
1 => '9'
'programCode' => array
0 => '03.02.01'
1 => '03.01.01'
'educationProgramName' => array
0 => 'Mathematics'
1 => 'Physics'
'total' => array
'totalFirstYear' => '22'
'totalSecondYear' => '17'
'programCode' => '-'
'totalEducationProgramName' => 'Total Directions'
Then the required structure should look something like this
array
'main' => array
'firstYearStudents' => array
0 => '10'
1 => '12'
2 => '22'
'secondYearStudents' => array
0 => '8'
1 => '9'
2 => '17'
'programCode' => array
0 => '03.02.01'
1 => '03.01.01'
2 => '-'
'educationProgramName' => array
0 => 'Mathematics'
1 => 'Physics'
2 => 'Total Directions'
I've tried the following but I got the named keys so I can't access these keys.
$i = 0;
foreach ($studentsEditInfo['main'] as $values) {
$studentsEditInfo['main'] = array_merge($values, $studentsEditInfo['total'][$i]);
$i++;
}
I don't know how to access the indices of my "total" array inside the foreach loop of my "main" array.