ASCII
This will help:
//Code to Character
echo chr(65);
//Character to Code
echo ord('A');
Unicode
But since these function work for ASCII, for Unicode:
function uniord($u) {
$k = mb_convert_encoding($u, 'UCS-2LE', 'UTF-8');
$k1 = ord(substr($k, 0, 1));
$k2 = ord(substr($k, 1, 1));
return $k2 * 256 + $k1;
}
echo uniord('ب');