The mb_chr() function is an inbuilt function in PHP that is used to return the character unicode point value that is encoded into the specified encoding.
Syntax:
string|false mb_chr(int $codepoint, string $encoding = null)
Parameters: This function accepts two parameters that are described below:
- $codepoint: This parameter holds the unicode code point value.
- $encoding: This parameter describes the character encoding. If this parameter value is omitted or null, the internal character encoding value will be used.
Return Value: This parameter returns a string that contains the requested character. It returns the specified encoding or false on failure.
Example 1: The following code demonstrates the PHP mb_chr() method.
PHP
<?php // Create an array with the character // unicode values $char_code = [71, 101, 101, 107, 115]; // Return the character for each // unicode array values foreach ( $char_code as $index ) { print_r(mb_chr( $index , 'ASCII' )); } ?> |
Geeks
Example 2: The following code is another example of the PHP mb_chr() method.
PHP
<?php // Create an array with character // unicode values $char_code = [0x71, 0x101, 0x104, 0x107, 0x115]; // Return the character for each // unicode array values foreach ( $char_code as $index ) { print_r(mb_chr( $index , 'UTF-8' )); } ?> |
qāĄćĕ
Reference: https://www.php.net/manual/en/function.mb-chr.php