Home>Article>Backend Development> How to convert float to int in php?
#How to convert float to int in php?
1. Use the function "intval" to convert float type data to int type;
$float = 15.222; intval($float);
2. Use "settype()" to set float type data to int type;
$float = 15.222; settype($float, 'int');
3. Add "(int)" in front of the variable to force it to int.
$float = 15.222; (int) $float;
Recommended tutorial: "PHP"
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!