Home >Backend Development >PHP Problem >How to convert float to int in php
How to convert float to int in php
Use round(x,prec) method
Parameters | Description |
x | Optional. Specifies the number to be rounded. |
prec | Optional. Specify the number of digits after the decimal point |
<?php echo(round(0.60)); echo(round(0.50)); echo(round(0.49)); echo(round(-4.40)); echo(round(-4.60)); 输出: 1 1 0 -4 -5
Recommended tutorial: "php tutorial"
The above is the detailed content of How to convert float to int in php. For more information, please follow other related articles on the PHP Chinese website!