Its quite simple, just write a foreach loop, to loop over one of the arrays, I used the $mins array here.
Then grab the equivalent data from each of the other arrays and add them all into your new array using the key as the key to the new array.
$mins = array(2006 => 117, 2007 => 117, 2008 => 117,
2009 => 117, 2010 => 117, 2011 => 117,
2012 => 118, 2013 => 132);
$avgs = array(2006 => 170, 2007 => 174, 2008 => 169,
2009 => 179, 2010 => 180, 2011 => 181,
2012 => 182, 2013 => 183);
$maxs = array(2006 => 217, 2007 => 233, 2008 => 322,
2009 => 215, 2010 => 216, 2011 => 217,
2012 => 231, 2013 => 232);
$newArray = array();
foreach( $mins as $year => $min ) {
$newArray[$year] = array( $min, $avgs[$year], $maxs[$year] );
}
print_r( $newArray );
Output is :-
Array
(
[2006] => Array
(
[0] => 117
[1] => 170
[2] => 217
)
[2007] => Array
(
[0] => 117
[1] => 174
[2] => 233
)
[2008] => Array
(
[0] => 117
[1] => 169
[2] => 322
)
[2009] => Array
(
[0] => 117
[1] => 179
[2] => 215
)
[2010] => Array
(
[0] => 117
[1] => 180
[2] => 216
)
[2011] => Array
(
[0] => 117
[1] => 181
[2] => 217
)
[2012] => Array
(
[0] => 118
[1] => 182
[2] => 231
)
[2013] => Array
(
[0] => 132
[1] => 183
[2] => 232
)
)
And using the new array syntax it would be
$mins = [2006 => 117, 2007 => 117, 2008 => 117,
2009 => 117, 2010 => 117, 2011 => 117,
2012 => 118, 2013 => 132];
$avgs = [2006 => 170, 2007 => 174, 2008 => 169,
2009 => 179, 2010 => 180, 2011 => 181,
2012 => 182, 2013 => 183];
$maxs = [2006 => 217, 2007 => 233, 2008 => 322,
2009 => 215, 2010 => 216, 2011 => 217,
2012 => 231, 2013 => 232];
$newArray = [];
foreach( $mins as $year => $min ) {
$newArray[$year] = [ $min, $avgs[$year], $maxs[$year] ];
}
print_r( $newArray );
And if you want the result as an array of string just change it like this
foreach( $mins as $year => $min ) {
$newArray[$year] = sprintf('[%d,%d,%d]', $min, $avgs[$year], $maxs[$year]);
}
print_r( $newArray );
Giving this result
Array
(
[2006] => [117,170,217]
[2007] => [117,174,233]
[2008] => [117,169,322]
[2009] => [117,179,215]
[2010] => [117,180,216]
[2011] => [117,181,217]
[2012] => [118,182,231]
[2013] => [132,183,232]
)