What's the easiest way to truncate a decimal to one decimal place?
52.3523% -> 52.3%
I was using floor($percent+.5), but I decided that I want truncation instead.
number_format()
If you want the value to continue to be a float type instead of a string, use round().
But if you want a consistent one-decimal display, use number_format(). With round(52.01, 1), e.g. your display will be "52", while with number_format(52.01, 1) it will be "52.0". And implicit casting will take care of most of the rest.
And just because there's always more than one way to do it, you could use printf() or sprintf():
$value = 52.01; printf('%.1f%%', $value); // outputs "52.0%"