PHP mb_chr() Function

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')); } ?> |
Output
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')); } ?> |
Output
qāĄćĕ
Reference: https://www.php.net/manual/en/function.mb-chr.php
Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, zambiatek 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!


