php 平均值和保留两位小数 不足补0

    public function getsum($array)
    {
        $weight = 0;
        $count = count($array);
        foreach ($array as $key => $value) {
            $weight+= $value['value'];
        }
        return sprintf("%1\$.2f", $weight/$count);
    }

你可能感兴趣的:(php 平均值和保留两位小数 不足补0)