Perform Calculations on an Array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

Perform Calculations on an Array

Post 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?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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
djwk
Forum Commoner
Posts: 56
Joined: Tue Mar 07, 2006 2:14 pm

Post by djwk »

Thanks, got it working fine :)
Post Reply