// Finish by bawnpa with help from aidan ##php@irc.freenode.net // Provided how many $widgets we need to produce, the below // function determines an amount that should be produced // considering we have $hours to manufacture the widgets. function distrib_production($widgets, $hours) { $hourly_base = floor($widgets/$hours); $overflow = $widgets-$hourly_base*$hours; $array = array_fill(1, $hours, $hourly_base); while ($overflow > 0) { $i++; $array[$i] = $array[$i] + 1; $overflow--; } // Cleanup unset($overflow); unset($i); unset($hourly_base); // return $array; }