Jump to content

Remove trailing zeroes after round()


hamaldus

Recommended Posts

Greetings!

 

Im struggling getting the following working:

I need to first strip down a decimal to one decimal.

Fair enough, just use round($val,1).

 

But after that, I need to remove the trailing zero, if there are any:

 

12.3444562 becomes 12.3

12.012 becomes 12

12.61 becomes 12.6

 

And so on. Is there an easy way to do this?

Thanks for all help:)

 

Link to comment
https://forums.phpfreaks.com/topic/148050-remove-trailing-zeroes-after-round/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.