Skip to content

intval ​

php
number intval(mixed $liczba, [number $baza])

Returns the integer part of $liczba.

The optional $baza argument specifies the numeric base for conversion, and applies only when the first argument is a string. Defaults to 10.

Example:

php
$a = 3;
$b = 2;
$c = intval(($a+$b)/2);
print("The integer part of the average of ".$a." and ".$b." is ".$c);

Result:

The integer part of the average of 3 and 2 is 2