Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.