Alright guys, Basically i've got some code which is working from an if
statement, I'm wondering if it's possible to recode it to work from a percentage, here's the current code
@sort($prices_array);
if ($prices_array[1] > 10000 AND $prices_array[1] < 50000) {
$sell_at = $prices_array[1] - 250;
} elseif ($prices_array[1] > 50000 AND $prices_array[1] < 100000) {
$sell_at = $prices_array[1] - 500;
} else {
$sell_at = $prices_array[1] - 100;
}
$buy_at = $prices_array[1] - 1000;
if ($prices_array[1] >= 10000) {
$buy_at = $buy_at - 1000;
if ($prices_array[1] >= 20000) {
$buy_at = $buy_at - 1000;
if ($prices_array[1] >= 30000) {
$buy_at = $buy_at - 1000;
}
if ($prices_array[1] >= 40000) {
$buy_at = $buy_at - 1000;
}
if ($prices_array[1] >= 50000) {
$buy_at = $buy_at - 750;
}
if ($prices_array[1] >= 60000) {
$buy_at = $buy_at - 500;
}
if ($prices_array[1] >= 70000) {
$buy_at = $buy_at - 500;
}
}
}
I know the code is quite horribly done, but would it be possible to base the $buy_at
from an certain percentage for example such as 5% lower than the sell_at
but rounded to the correct decrements from the if
statement