mb_chr

(PHP 7 >= 7.2.0)

mb_chrGet a specific character

说明

mb_chr ( int $cp [, string $encoding ] ) : string

Warning

本函数还未编写文档,仅有参数列表。

参数

cp

encoding

返回值

Returns a specific character 或者在失败时返回 FALSE.

参见

  • mb_ord() - Get code point of character
  • chr() - 返回指定的字符

User Contributed Notes

boss3333 at laposte dot net 20-Apr-2019 02:43
To convert the utf16 or utf8 decimal values (utf-8 can translate both encodings) to ascii characters using mb_ord, follow these steps:

Starting value:

1_Zvpxs4pf

Value converted to decimal value utf-16 or utf-8 (see ascii coding table):

49,95,90,118,112,120,115,52,112,102

recovery with mb_ord:

use: $ char = mb_chr ($ decimalValue, 'UTF-8');
return the correct character;

1, _, Z, v, p, x, s, 4, p, f

example:
$ start_String = 1_Zvpxs4pf;
$ start_String_to_Decimal = 49959011811212011552112102;
(decimal value of each character add in an array);
$ tab = [49, 95, 90, 118, 112, 120, 115, 52, 112, 102];
$ size = sizeof ($ tab);

$ tmpStr = '';

for ($ i = 0; $ i <$ size; $ i ++)
{
$ tmpStr. = mb_chr ($ tab [$ i], 'UTF-8');
}

echo $ tmpStr;

1_Zvpxs4pf