Open In App

PHP | IntlChar getNumericValue() Function

Last Updated : 27 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
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
<?php 
// PHP program to illustrate the use of
// IntlChar::getNumericValue() Function
    
// Input int codepoint value 
var_dump(IntlChar::getNumericValue("2")); 
    
// Input int codepoint value 
var_dump(IntlChar::getNumericValue("4")); 
    
// Input char codepoint value 
var_dump(IntlChar::getNumericValue("G")); 
    
// Input string codepoint value 
var_dump(IntlChar::getNumericValue("Geeks")); 

// Input Symbolic codepoint value 
var_dump(IntlChar::getNumericValue("$")); 

// Input Symbolic codepoint value 
var_dump(IntlChar::getNumericValue("\u{216C}")); 

// Input Symbolic codepoint value 
var_dump(IntlChar::getNumericValue("\u{216F}")); 

?> 
Output:
float(2)
float(4)
float(-123456789)
NULL
float(-123456789)
float(50)
float(1000)
Example 2: php
<?php 
// PHP program to illustrate the use of 
// IntlChar::getNumericValue() Function 

// Declare an array with 
// different codepoint value 
$arr = array("4", 
            "1",
            "Geeks",
            "\u{216C}", 
            "\u{216F}", 
            65, 
        ); 
    
// For loop condition to check 
// each character through function 
foreach ($arr as $val) { 
        
    // Check each element as code point data 
    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

Next Article
Article Tags :

Similar Reads