Okay - I am at this point and seem to have got quite far.
function findprices($low=0, $high=1000, $increments=6)
{
// Highest Price
$highest = rounddown($high);
// Lowest Price
$lowest = $low;
$difference = $highest-$lowest;
$amount_between = ceil($difference/$increments);
$price_to = $lowest+$amount_between;
$i = 1;
$output = array();
while ($price_to < $highest)
{
//$output[] = $lowest;
if ($lowest == 0)
{
$output[] = '0,'.$price_to;
}
elseif ($i == $increments-1)
{
$output[] = $lowest;
}
else
{
$output[] = $lowest.','.$price_to;
}
$i++;
$price_to = $price_to + $amount_between;
$lowest = $lowest + $amount_between;
}
return array_values($output);
}
Echoing out the result of this function gives you this:
Array
(
[0] => 0,167
[1] => 167,334
[2] => 334,501
[3] => 501,668
[4] => 668
)
So it doesn't exactly work how it should.
Problems:
Seems to always stop at 668
I am looking for equal increments
Say I have 6 increments, that would be 0-149, 150-299, 299-450 etc etc
Could someone help me out here?