

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP – How to get the Unicode point value of a given character?
In PHP, we can use the mb_ord() function to get the Unicode code point value of a given character. This function is supported in PHP 7 or higher versions. The mb_ord() function complements the mc_chr() function.
Syntax
int mb_ord($str_string, $str_encoding)
Parameters
mb_ord() accepts the following two parameters −
$str_string − This parameter is used for the string.
$str_encoding − This is the character encoding parameter. If it is absent or NULL, then we can use the internal encoding value.
Return Values
mb_ord() returns the Unicode point value for the first character from the given string. It will return False on failure.
Example
<?php echo "Get the numeric value of character \n"; var_dump(mb_ord("B", "UTF-8")); var_dump(mb_ord("d", "UTF-8")); var_dump(mb_ord("\x80", "ISO-8859-2")); var_dump(mb_ord("\x80", "Windows-1251")); ?>
Output
It will produce the following output −
Get the numeric value of characters int(66) int(100) int(128) int(1026)
- Related Questions & Answers
- PHP – How to return character by Unicode code point value using mb_chr()?
- How to return a number indicating the Unicode value of the character?
- How to find the unicode category for a given character in Java?
- Java Program to Determine the Unicode Code Point at a given index
- Convert the value of the specified string to its equivalent Unicode character in C#
- How to print Unicode character in C++?
- Check whether the Unicode character is a separator character in C#
- PHP – How to get the substitution character using mb_substitute_character()?
- Get the hyperbolic arc-cosine of a floating-point value in C#
- Java Program to Get a Character From the Given String
- How to fetch character from Unicode number - JavaScript?
- How to convert an integer to a unicode character in Python?
- How to correctly get a value from a JSON PHP?
- Get the hyperbolic cosine of a given value in Java
- Get the hyperbolic sine of a given value in Java
Advertisements