Page 1 of 1

Perform Calculations on an Array

Posted: Tue Jan 23, 2007 2:57 am
by djwk
Lets say I have an array with the following contents:

"3, 10, 6, 9, 2, 8, 5"

How would I go about adding all of the numbers in the array together and dividing by how many numbers there are?

Posted: Tue Jan 23, 2007 3:05 am
by volka
There's a function to sum up the elements of an array and there's a function to count the elements in an array. You find both listed at http://de3.php.net/array

Posted: Tue Jan 23, 2007 3:47 am
by djwk
Thanks, got it working fine :)