Jump to content

Archived

This topic is now archived and is closed to further replies.

rugzo

array average

Recommended Posts

Hi all,

 

i couldn't find expression for average. There are many of them like

 

sum(array)

max(array)

 

but couldn't find something like

 

avg(array)

 

?

Share this post


Link to post
Share on other sites

Simple math, asuuming by average you mean mean

$average = array_sum($array) / count($array);

Share this post


Link to post
Share on other sites

function average($array) {
return array_sum($array) / count($array);
}

Works out the mean.

Share this post


Link to post
Share on other sites

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.