Returns the integer value of var, using the specified base for the conversion (the default is base 10).
PHP intval() function has the following syntax.
int intval ( mixed $var [, int $base = 10 ] )
If base is 0, the base used is determined by the format of var:
The integer value of var on success, or 0 on failure.
Find out the int value
<?php/*from w w w . j av a 2s . c om*/
echo intval(2) . "\n"; // 2
echo intval(4.1) . "\n"; // 4
echo intval('4') . "\n"; // 4
echo intval('+42') . "\n"; // 42
echo intval('-42') . "\n"; // -42
echo intval(042) . "\n"; // 34
echo intval('04') . "\n"; // 4
echo intval(1e10) . "\n"; // 1410065408
echo intval('1e10') . "\n"; // 1
echo intval(0x1A) . "\n"; // 26
echo intval(42, 8) . "\n"; // 42
echo intval('42', 8) . "\n"; // 34
echo intval(array()) . "\n"; // 0
echo intval(array('foo', 'bar')) . "\n"; // 1
?>
The code above generates the following result.