Click here to Skip to main content
16,018,904 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How can I add or subtract amount based on decimal points in PHP / CI? I.e. if the amount is 5.11 it should return 5 and if amount is 5.66 it should return 6. Subtract +1 if decimal is greater then 50 and subtract if lesser or equal to 50

What I have tried:

We can use decimal detection and then ceil and floor function accordingly but seeking if there is library or function avaliable
Posted
Updated 16-Oct-18 16:57pm

1 solution

What you've described is just normal rounding (unless I am missing something)

PHP accomplishes this with the round function.

round(5.11);
round(5.6);

Round function documentation

PHP: round - Manual[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900