I want to somehow round the numbers for a rating system in PHP as follows:
4.6667 = 4.6 5.0001 = 5.0
Is there any way to do this? (BTW, I read the data from the database.)
You do not agree with any rule. For instance:
4.6667 = 4.6 5.0001 = 5.1
See these functions anyway:
roundceilfloor
And number_format .
Use this:
echo round(1.45667, 2);
The number "2" is the number of decimal places you want.
This is conclusion 1.46.
Source: https://habr.com/ru/post/1309971/More articles:Test Automation Using JUnit - javaUsing Basic Authentication in Firefox - httpCreating Web Pages Using Visual Studio 2010 Express - visual-studioAnalysis services with an excellent interface - is it possible to get a more convenient interface that powerpivot provides - sql-serverHow to determine which class is executed if an interface property is deserialized inside the class? - c #XAML Summary Table by Moshe Pasumanski - c #Use binding to display div - jqueryWhat are the βbasicβ methods of extreme programming? - agileTibco jms configuration with Spring - javaGoogle Maps displays the route between two points - javascriptAll Articles