欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

php获取中文的拼音代码

程序员文章站 2022-05-10 17:52:55
...

php获取中文的拼音代码

获取中文的拼音代码


 160)
			{
				$_Q = ord(substr($chinese, ++$i, 1));
				$_P = $_P * 256 + $_Q - 65536;
			}
			$result .= ($ucfirst ? ucfirst(self::_pinyin($_P, $data)) : self::_pinyin($_P, $data));
		}

		return preg_replace("/[^a-z0-9]*/i", '', $result);
	}

	private static function _pinyin($num, $data) {
		if ($num > 0 && $num  -10247)
			return '';
		else
		{
			foreach ($data as $k => $v)
			{
				if ($v > 6);
			$string .= chr(0x80 | $c & 0x3F);
		}
		elseif ($c > 12);
			$string .= chr(0x80 | $c >> 6 & 0x3F);
			$string .= chr(0x80 | $c & 0x3F);
		}
		elseif ($c > 18);
			$string .= chr(0x80 | $c >> 12 & 0x3F);
			$string .= chr(0x80 | $c >> 6 & 0x3F);
			$string .= chr(0x80 | $c & 0x3F);
		}

		return iconv('UTF-8', 'GB2312', $string);
	}

}

?> 
相关标签: 拼音 代码