Jump to content

[SOLVED] What to do this such cases ? I am confused


ankur0101

Recommended Posts

Hi,

 

$percentage = '72.76986325'

 

How can make it 73 ? after 72., its 7 which is greater than 5

If number is greater than or equal to 5, then add 1 to previous number

 

Like this

 

72.86669856, then it should be 73

 

72.23669994, then it should be 72

 

How to do that in PHP ?

round should do it.

 

Parameters

val

    The value to round

precision

    The optional number of decimal digits to round to, defaults to 0

mode

    One of PHP_ROUND_HALF_UP, PHP_ROUND_HALF_DOWN, PHP_ROUND_HALF_EV

 

Set the mode to PHP_ROUND_HALF_UP and it should work like you want, but that is the default I believe so it is not necessary to specify it.

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.