| Viewed 210 times

How to remove decimals in PHP?


How to remove decimals in PHP?

PHP
1 Answer
Mohammad Qandeel
Answered
10

to remove decimals in PHP can be easily done through

casting to integer

Example 

<?php
    $number = 199.66;
    $number = (int)$number;//convert to int 
    echo $number;
?>

Output

199

intval() function

this function will return the integer value of the variable

Example 

<?php
    $number = 199.66;
    $number = intval($number);//convert to int 
    echo $number;
?>

Output

199