I’m trying to have an array of prices as input and the output result for a set like 56,76,103,149,159,239,289, would be something like array([0]=>array([min]=>39,[max]=>59),array([min]=>59,[max]=>79),array([min]=>99,[max]=>199),array([min]=>199,[max]=>299))

what i had in mind was for the function to accept the prices values, iterate them an place them in the respective range. This is one of the many different approaches i tried out. It is not prety nor does it work correctly but this is the big idea
function price_range($items,$index=1)
{
$maxPrice = ceil(max($items));
for ($i=0,$j=strlen(floor($maxPrice));count($items) >$i;$i++)
{
$range = pow(10, (strlen(floor($items[$i]))-$index));
$tmp[$range] = $items[$i];
}
if (count($tmp) == 1) {
$tmp = array();

return $tmp;
}
else {
return $tmp;
}

}

The input is a flat array of all the prices. The output is an array of the ranges. Which works great if all your prices are in different powers of 10, but fails if they are on the same power.