I’m looking to round so that the zero is included, for example:
We round 2.99 to 3, so it displays 3. I want it to instead display 3.0.
I’m going to move this value to the database afterwards, if that matters.
I’ve found a solution with sprintf, which didn’t work due to the reason mentioned above.
Do
number_format(round(2.99, 1), 1). First it rounds to the proper position, then add a zero (and turns it into a string).But you do NOT need the .0 in your database – it will ignore that. Not only that but it will be a string, so it might not work right with bound variables.
If you want the .0 to show in the database output you may be able to configure that.