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 returnd
$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

* indicates required
Subscribe to plus2net

    plus2net.com







    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2021 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer