intval() to get integer from data in php
We can use intval to get integer part
intval($value, $base );
$value : the data which integer is returned
$base : optional , base to consider
Examples using intval()
Code with output
echo intval(23); // 23
echo "<br>";
echo intval('23'); // 23
echo "<br>";
echo intval('23.34'); // 23
echo "<br>";
echo intval('023'); // 23
echo "<br>";
echo intval(023); // 19
echo "<br>";
echo intval('23',8); // 19
echo "<br>";
echo intval('2e10'); // 2
echo "<br>";
echo intval(2e10); // -1474836480
←ctype_digit() FILTER_VALIDATE_INT() → is_numeric() → is_numeric() →
← PHP Form ctype_alpha():Alphabetic chars only →
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com