This function takes each few elements of an array and averages them together. It then places the averages in a new array. It is used to smooth out data. For example lets say you have a years worth of hit data to a site and you want to graph it by the week. Then use a bucket of 7 and graph the functions output.
function array_bucket($array, $bucket_size) // bucket filter
{
if (!is_array($array)) return false; // no empty arrays
$buckets=array_chunk($array,$bucket_size); // chop up array into bucket size units
foreach ($buckets as $bucket) $new_array[key($buckets])=array_sum($bucket)/count($bucket);
return $new_array; // return new smooth array
}