rendered paste body<?php/*** waverage** Average based on the times of repetance** @author Kiensan Chea <ksan_chea@hotmail.com>* @access public* @param array, all the votes* @return int*/function waverage($votes = array()){ $votesPerValue = array(); $weight = 10; foreach($votes as $value){ if(!array_key_exists($value, $votesPerValue)){ $votesPerValue[$value] = 1; } else{ $votesPerValue[$value]++; } } $sum = 0; foreach($votesPerValue as $key => $value){ $sum += pow($key,$weight)*$value; } $waverage = pow(($sum/sizeof($votes)),1/$weight); return $waverage;}/*** average** Average** @author Kiensan Chea <ksan_chea@hotmail.com>* @access public* @param array, all the votes* @return int*/function average($votes = array()){ $sum = 0; foreach($votes as $value){ $sum += $value; } $average = $sum/count($votes); return $average;}$votes = array(1,10,10,10);print_r($votes);echo '<br />waverage: '.waverage($votes);echo '<br />average: '.average($votes);?>