Home > Backend Development > PHP Problem > How to convert float to int in php

How to convert float to int in php

hzc
Release: 2023-03-01 16:12:01
Original
2284 people have browsed it

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
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template