'Scuse my ignorance but what is the neatest way to total all the values of an array?
i.e.
$array==(1,2,3,5) $total==11
Thanks
Loop through the elements and add them up. If it's an indexed array, just say
for ($i = 0; $i < sizeof($arr); $i++) ...
If associative, use foreach().
$array = array(1, 4, 6, 8, 3); //Loop through the array for ($i=0;$i<count($array);$i++) { //And keep a running total $total += $array[$i]; } //Print the total or do whatever print $total;
Thanks very much! += was the education I needed!