View Full Version : Average values?

03 March 2006, 04:35 PM
Hey all, been awhile for me and scripting...have a simple question. How do I:

Iterate through an array and average the values in it. However, for each array entry, I want the loop to check against a global
variable to determine whether or not it is considered in the averaging. Thus each array entry will actually have a checkbox
where the user can select whether said entry is condsidered in the averaging.

03 March 2006, 07:51 PM
howabout something like:

float $total = 0;
float $count = 0;
for ($each in $all){
$total = $total+$each;
float $average = $total/$count;

CGTalk Moderation
03 March 2006, 07:51 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.