php得到所有的汉字

<?php
header('Content-Type: text/html;charset=utf8');
//输出所有汉字
$start = hexdec('4e00');
$end = hexdec('9fa5');

for($i=$start; $i<$end; $i++) {
    print_r(json_decode('["\u'.dechex($i).'"]'));
}

总结: 4e00为汉字十六进制的下界,9fa5为汉字十六进制的上界,我们遍历每一个汉字的十六进制对应得十进制码,然后再通过json_decode解码得到最终的汉字。

posted on 2013-04-30 15:01  mtima  阅读(374)  评论(0编辑  收藏  举报

导航