<?php

#
# Creates a new array consisting of the sum of the elements
# per index of the passed arrays.
#
# @param $array1 [$array2 [...]]
#     the arrays to sum the values per index of.
#
# @return $array
#   consisting of the sum of the elements per index of the
#   passed arrays.
#

$array1 = array(1,1,1);
$array2 = array(1,2,1);

function 
array_sum_by_index($array1$array2) {
    
array_unshift($args func_get_args(), null);
    return 
array_map('array_sum'call_user_func_array('array_map'$args));
}

print_r(array_sum_by_index($array1$array2));

?>