With php round function it will make it simpler
round — Rounds a float
round ( float $val , int $precision = 0 , int $mode = PHP_ROUND_HALF_UP ) : float
Example: Round 24.8888 to 24.9 with 1 precision
round(24.8888, 1); // 24.9
With str_replace
replace ',' to '.' and floatval
evaluate the string value to float. Because round function need only a float param in first argument. And the function should be like this one
function getRatePrecision($rate)
{
return round(floatval(str_replace(',', '.', $rate)), 1);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…