$a = array(2, 6, 24, 16, 7, 10);
I know how to add all the numbers using array_sum()
but if I want to add only the numbers between 2
and 16
how can do that?
This is one of the solution that that I've come up with:
$a = array(2, 6, 24, 16, 7, 10);
$r = array_slice($a, 0, -2);
print_r (array_sum($r));
Just want to know if there is any other way to get the result.