I have one android application in which I am using PHP API for get data from server. This is quote application and in which I have function of counting likes and shares of quotes. I am converting that count in k style number like 1K for 1000 etc with below function.
function Get_convert_to($value)
{
if ($value > 999 && $value <= 999999) {
$result = floor($value / 1000) . ' K';
} elseif ($value > 999999) {
$result = floor($value / 1000000) . ' M';
} else {
$result = $value;
}
return $result;
}
Now my issue is its returning 1K for even 1400....I want 1.4K for 1400. How can I do that?
Thanks
To get value like 1.4 (one decimal) use parameter to control decimal
Output:
1.4K