Shamim Ahmed
Shamim Ahmed

Reputation: 931

How do I round only floating digit in PHP?

I have a php output 14.85, i want to make it 14.90 for 14.50 and for 14.47. I am trying with round function but i am not getting right number format, Is it possible ?

thanks

Upvotes: 2

Views: 57

Answers (2)

Mureinik
Mureinik

Reputation: 310993

number_format(round($var, 1), 2) should do the trick.

Upvotes: 2

Mina
Mina

Reputation: 1516

As in most of programming languages you can use ceil(), floor() or round()

Upvotes: 0

Related Questions