I'm trying to round a float to the nearest quarter, with three decimal places, but I can't seem to do it in PHP. Here's what I've got so far:
$longitude = 145.6360003;
echo floor($longitude * 4) / 4;
I get 145.5
back, but the value I'm looking for is 145.625
. I also tried this snippet from the php.net comments but still nothing.
How do I trim a number to 3 decimal places, then round to the nearest quarter, preserving the three decimal places?