//编码不能为utf-8, 如果是utf8可以改为gb2312
//如:iconv("utf-8","gb2312",'杭州')
 0 && $num < 160){ 
		return chr($num); 
	} 
	//非法字符
	elseif($num < -20319 || $num > -10247){ 
		return ""; 
	}
	//中文
	else{ 
		for($i = count($d) - 1; $i >= 0; $i--){
			if($d[$i][1] <= $num)
				break;
		} 
		return $d[$i][0];  
	} 
} 

function pinyin($str){ 
	$ret = ""; 
	for($i = 0; $i < strlen($str); $i++){ 
		$p = ord(substr($str, $i, 1)); 
		if($p > 160){ 
			$q = ord(substr($str, ++$i,1)); 
			$p = $p*256 + $q - 65536; 
		} 
		$ret .= g($p); 
	} 
	return $ret; 
} 
?> 

参考链接:http://blog.csdn.net/riyao/article/details/530963

标签: none

评论已关闭