PHP | IntlChar getNumericValue() Function
The IntlChar::getNumericValue() function is an inbuilt function in PHP which is used to get the numeric value for a Unicode code point as defined in the Unicode Character Database.
Syntax:
float IntlChar::getNumericValue( $codepoint )
Parameters: This function accepts a single parameter $codepoint which is mandatory. The input parameter is a character, which is encoded as a UTF-8 string.
Return Value: This function returns the numeric value of codepoint on success, or IntlChar::NO_NUMERIC_VALUE if none is defined.
Below programs illustrate the IntlChar::getNumericValue() function in PHP:
Example 1:
<?php
var_dump(IntlChar::getNumericValue( "2" ));
var_dump(IntlChar::getNumericValue( "4" ));
var_dump(IntlChar::getNumericValue( "G" ));
var_dump(IntlChar::getNumericValue( "Geeks" ));
var_dump(IntlChar::getNumericValue( "$" ));
var_dump(IntlChar::getNumericValue( "\u{216C}" ));
var_dump(IntlChar::getNumericValue( "\u{216F}" ));
?>
|
Output:
float(2)
float(4)
float(-123456789)
NULL
float(-123456789)
float(50)
float(1000)
Example 2:
<?php
$arr = array ( "4" ,
"1" ,
"Geeks" ,
"\u{216C}" ,
"\u{216F}" ,
65,
);
foreach ( $arr as $val ) {
var_dump(IntlChar::getNumericValue( $val ));
}
?>
|
Output:
float(4)
float(1)
NULL
float(50)
float(1000)
float(-123456789)
Reference: http://php.net/manual/en/intlchar.getnumericvalue.php
Last Updated :
27 Aug, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...