I am using a function to make 1000 to 1k and 1000000 to 1m but i want to add one decimal to it, i have gotten this far but it rounds up instead of down so if i enter 1565 i want to get 1.5 and only if i pass 1600 i want to get 1.6 (force round down) i use this function:
public function convert($Input){
if($Input<1000){
$AmountCode = "";
$Amount = $Input;
}
else if($Input>=1000000){
$AmountCode = "M";
$Amount = round(floatval($Input / 1000000), 1, PHP_ROUND_HALF_DOWN);
}
else if($Input>=1000){
$AmountCode = "K";
$Amount = round($Input / 1000, 1, PHP_ROUND_HALF_DOWN);
}
$Array = array(
'Amount' => $Amount,
'Code' => $AmountCode
);
return $Array;
}
Scenario 1: what happens now if i enter 1565 i get 1.6 and if i enter 1545 i get 1.5 does any one know how to get the forcibly round it down?
Scenario 2: the number i enter is 10665 will be outputted as 10.7k (rounded up), but i want to to show as 10.6k (rounded down) which for somereason i can't figure out how to do that