Friday, October 10, 2025
HomeLanguagesPHP IntlChar::ord() Function

PHP IntlChar::ord() Function

The IntlChar::ord() function is an inbuilt function in PHP which is used to return the Unicode code point value of the given character.

Syntax: 

int IntlChar::ord( $character )

Parameters: This function accepts a single parameter $character which is mandatory. This parameter is a Unicode character.

Return Value: It returns the Unicode code point value as an integer.

Below examples illustrate the IntlChar::ord() Function in PHP:

Example 1: In this example, we will use the ord() function.

PHP




<?php
// PHP function to illustrate 
// the use of IntlChar::ord()
    
// Input int codepoint value 
var_dump(IntlChar::ord("4"));
    
// Input character codepoint value 
var_dump(IntlChar::ord("B"));
    
// Input character codepoint value 
var_dump(IntlChar::ord("b"));
    
//Input int codepoint value 
var_dump(IntlChar::ord("2018"));
    
// Input character codepoint value 
var_dump(IntlChar::ord("Geeks"));
    
// Input symbolic codepoint value 
var_dump(IntlChar::ord("@"));
  
// Input symbolic codepoint value 
var_dump(IntlChar::ord("*"));
  
// Input space codepoint value 
var_dump(IntlChar::ord(" "));
?>


Output: 

int(52)
int(66)
int(98)
NULL
NULL
int(64)
int(42)
int(32)

Example 2: In this example, we will use the ord() function.

PHP




<?php
// PHP function to illustrate the
// use of IntlChar::ord()
    
// Declare an array with
// different codepoint value 
$arr = array("X",
            "x"
            "*",
            "8",
            "0",
            " ",  
            "&"
            ")"
            "99"
        );
      
// For loop condition to check 
// each character through function
foreach ($arr as $val) {
          
    // Check each element as code point data
    var_dump(IntlChar::ord($val));
}
?>


Output: 

int(88)
int(120)
int(42)
int(56)
int(48)
int(32)
int(38)
int(41)
NULL

Related Articles:  

Reference: http://php.net/manual/en/intlchar.ord.php

RELATED ARTICLES

Most Popular

Dominic
32350 POSTS0 COMMENTS
Milvus
87 POSTS0 COMMENTS
Nango Kala
6718 POSTS0 COMMENTS
Nicole Veronica
11880 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11941 POSTS0 COMMENTS
Shaida Kate Naidoo
6838 POSTS0 COMMENTS
Ted Musemwa
7100 POSTS0 COMMENTS
Thapelo Manthata
6794 POSTS0 COMMENTS
Umr Jansen
6794 POSTS0 COMMENTS