I have two arrays:
$a = array(10, 2, 5, 10, 0);
$b = array(1, 20, 11, 8, 3);
I need to sum up and get the result:
$c = array(11, 22, 16, 18, 3);
Any suggestions on how do this without "foreach"?
I have two arrays:
$a = array(10, 2, 5, 10, 0);
$b = array(1, 20, 11, 8, 3);
I need to sum up and get the result:
$c = array(11, 22, 16, 18, 3);
Any suggestions on how do this without "foreach"?
There's no way you can do that without the "foreach" as you asked for, you need to loop on both arrays to get the respective values.
A function using the foreach would be :
Now you just need to do :
Try like
a simple approach could be
Or if you could use PHP5.6, you could also use variadic functions like this
Output