The IntlChar::charDigitValue() function is an inbuilt function in PHP which is used to return the decimal digit value from a decimal digit character. Where the general category decimal digit numbers and “Nd” is Numeric_Type of Decimal.
Syntax:
int IntlChar::charDigitValue( $codepoint )
Parameters: This function accepts a single parameter $codepoint which is mandatory. The input parameter is a character or integer value, which is encoded as a UTF-8 string.
Return Value: If $codepoint is decimal digit value then returns True otherwise return -1.
Below programs illustrate the IntlChar::charDigitValue() Function in PHP.
Program 1:
php
<?php
var_dump(IntlChar::charDigitValue( "\u{2025}" ));
echo "<br>" ;
var_dump(IntlChar::charDigitValue( "2345" ));
echo "<br>" ;
var_dump(IntlChar::charDigitValue( "\u{0774}" ));
echo "<br>" ;
var_dump(IntlChar::charDigitValue( "2" ));
echo "<br>" ;
var_dump(IntlChar::charDigitValue( "Geeks" ));
echo "<br>" ;
var_dump(IntlChar::charDigitValue( "\u{0E66}" ));
echo "<br>" ;
var_dump(IntlChar::charDigitValue( " " ));
?>
|
Output:
int(-1)
NULL
int(-1)
int(2)
NULL
int(-1)
int(-1)
Program 2:
php
<?php
$arr = array ( "^" , "2345" , "6" , "\n" );
foreach ( $arr as $val ){
var_dump(IntlChar::charDigitValue( $val ));
echo "<br>" ;
}
?>
|
Output:
int(-1)
NULL
int(6)
int(-1)
Related Articles:
Reference: http://php.net/manual/en/intlchar.chardigitvalue.php
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!