charCodeAt()函数方法可返回指定位置的字符的 Unicode 编码。这个返回值是 0 – 65535 之间的整数。
JavaScript里经常看到charCodeAt函数但有些时候需要转换为php,找了一下,有篇博客提到了,代码如下:

function get_bianma($str){
$result = array();
for($i = 0, $l = mb_strlen($str, "utf-8");$i < $l;++$i){
$result[] = uniord(mb_substr($str, $i, 1, "utf-8"));
}
return join(",", $result);
}
function uniord($str, $from_encoding = false){
$from_encoding = $from_encoding ? $from_encoding : "UTF-8";
if (strlen($str) == 1){return ord($str);}
$str = mb_convert_encoding($str, "UCS-4BE", $from_encoding);
$tmp = unpack("N", $str);
return $tmp[1];
}

代码整理自:http://www.hhtjim.com/the-php-version-of-the-charcodeat-function.html

Related Posts: PHP-charCodeAt()函数 :