php8.5
Home/ Manual/ mbstring / functions/ mb_ord

mb_ord

PHP function Edit on GitHub ✎

(PHP 7 >= 7.2.0, PHP 8)

Get Unicode code point of character

Description

mb_ord(string $string, string|null $encoding = null): int|false

Returns the Unicode code point value of the given character.

This function complements mb_chr().

Parameters

string

A string

encoding

Parameter

Return Values

The Unicode code point for the first character of string Falseforfailure.

Changelog

VersionDescription

Examples

A basic mb_ord() example

php
<?php
var_dump(mb_ord("A", "UTF-8"));
var_dump(mb_ord("🐘", "UTF-8"));
var_dump(mb_ord("\x80", "ISO-8859-1"));
var_dump(mb_ord("\x80", "Windows-1252"));
?>

The above example will output:

output
int(65)
int(128024)
int(128)
int(8364)
    

See Also

Source: reference/mbstring/functions/mb-ord.xml · from the official PHP manual (php/doc-en)