[ create a new paste ] login | about

Link: http://codepad.org/3gPExrhO    [ raw code | output | fork ]

PHP, pasted on Nov 8:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
function array_transpose($arr) {
   $map_args = array_merge(array(NULL), $arr);
   return call_user_func_array('array_map', $map_args);
}

$arr = array( 
  0 => array(0 => 0, 1 => 20, 2 => 5), 
  1 => array(0 => 5, 1 => 0,  2 => 15), 
  2 => array(0 => 5, 1 => 10, 2 => 0)
);

$maxes = array_map('max', array_transpose($arr));

print_r($maxes);
?>


Output:
1
2
3
4
5
6
Array
(
    [0] => 5
    [1] => 20
    [2] => 15
)


Create a new paste based on this one


Comments: