Friday, October 24, 2025
HomeLanguagesPHP | IntlChar getNumericValue() Function

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 
// 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 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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen 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!
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS