将一个数值切成N份 返加一个数组
/**
* 将一个数值切成N份
* @param int $number 切的数值
* @param int $avgNumber 份数
* @return array
*/
function numberAvg($number, $avgNumber)
{
if ($number == 0) {
$array = array_fill(0, $avgNumber, 0);
} else {
$avg = floor($number / $avgNumber);
$ceilSum = $avg * $avgNumber;
$array = array();
for ($i = 0; $i < $avgNumber; $i++) {
if ($i < $number - $ceilSum) {
array_push($array, $avg + 1);
} else {
array_push($array, $avg);
}
}
}
return $array;
}