Zils Zils - 3 years ago 264
PHP Question

using array_sum() except last value


is an array contains 5,10,15,20,60
how to exclude last value 60 and sum the rest? like 5+10+15+20

I'm using
but need to calculate without the last value, where
is to calculate all values.

Answer Source
array_sum($payamount) - end($payamount)

end — Set the internal pointer of an array to its last element

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download