Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the PHP equivlent of fromCharCode?

Is there a PHP function that takes an integer and return the Unicode character of that number?

like image 531
qwertymk Avatar asked Mar 26 '12 19:03

qwertymk


1 Answers

No, but you can easily make one:

<?php
/**
 * Return unicode char by its code
 *
 * @param int $u
 * @return char
 */
function unichr($u) {
    return mb_convert_encoding('&#' . intval($u) . ';', 'UTF-8', 'HTML-ENTITIES');
}
?>

Taken from: PHP Manual - chr - comments

like image 134
Madara's Ghost Avatar answered Nov 01 '22 22:11

Madara's Ghost