php 汉字转拼音类 支持音字 声调

突然要用到 utf-8 汉字转拼音 ,网上大多都是先把 utf-8 转成 gbk 在转成拼音,太麻烦了,于是自己整理了一份 utf-8 版的,由于找到到的码表问题,部分多音字及声调得到整理,算是比较全的汉字拼音表了。 当然和大多数转换程序一样,还不支持自动多音转换,如 银行可能会转换成 yinxing ,当然了,可以自己控制输出,需要汉字拼音表的可以在程序中提取。

<?php
/**
 * ch to pinyin
 * Enter description here ...
 * @author andsky
 *
 */
class Pinyin{
 
	private static $_instance;
	private $_dictionary = array(
    '吖'=>array(array(1,'a'), array(1,'ya')),
    '阿'=>array(array(1,'a'), array(3,'a'), array(4,'a'), array(1,'e')),
    '呵'=>array(array(1,'a'), array(0,'a'), array(1,'ha'), array(1,'he'), array(1,'ke')),
    '啊'=>array(array(1,'a'), array(2,'a'), array(3,'a'), array(4,'a'), array(0,'a')),
    '錒'=>array(array(1,'a')),
    '醃'=>array(array(1,'a'), array(1,'yan')),
    '嗄'=>array(array(2,'a'), array(4,'sha')),
    '哎'=>array(array(1,'ai')),
    '哀'=>array(array(1,'ai')),
    '埃'=>array(array(1,'ai')),
    '挨'=>array(array(1,'ai'), array(2,'ai')),
    '唉'=>array(array(1,'ai'), array(4,'ai')),
    '娭'=>array(array(1,'ai'), array(0,'xi')),
    '誒'=>array(array(1,'ai')),
    '噯'=>array(array(1,'ai'), array(3,'ai'), array(4,'ai')),
    '鎄'=>array(array(1,'ai')),
    '騃'=>array(array(2,'ai')),
    '皚'=>array(array(2,'ai')),
    '癌'=>array(array(2,'ai')),
    '佁'=>array(array(3,'ai'), array(3,'yi')),
    '欸'=>array(array(3,'ai'), array(1,'ei')),
    '矮'=>array(array(3,'ai')),
    '藹'=>array(array(3,'ai')),
    '靄'=>array(array(3,'ai')),
    '艾'=>array(array(4,'ai'), array(4,'yi')),
    '阨'=>array(array(4,'ai')),
    '砹'=>array(array(4,'ai')),
    '愛'=>array(array(4,'ai')),
    '僾'=>array(array(4,'ai')),
    '餲'=>array(array(4,'ai'), array(2,'he')),
    '隘'=>array(array(4,'ai')),
    '薆'=>array(array(4,'ai')),
    '礙'=>array(array(4,'ai')),
    '嗌'=>array(array(4,'ai'), array(4,'yi')),
    '嬡'=>array(array(4,'ai')),
    '靉'=>array(array(4,'ai')),
    '璦'=>array(array(4,'ai')),
    '曖'=>array(array(4,'ai')),
    '鑀'=>array(array(4,'ai')),
    '噫'=>array(array(4,'ai'), array(1,'yi'), array(4,'yi')),
    '廠'=>array(array(1,'an'), array(3,'chang')),
    '廣'=>array(array(1,'an'), array(3,'guang')),
    '安'=>array(array(1,'an')),
    '桉'=>array(array(1,'an')),
    '氨'=>array(array(1,'an')),
    '庵'=>array(array(1,'an')),
    '諳'=>array(array(1,'an')),
    '媕'=>array(array(1,'an')),
    '鵪'=>array(array(1,'an')),
    '腤'=>array(array(1,'an')),
    '鮟'=>array(array(1,'an')),
    '鞍'=>array(array(1,'an')),
    '盫'=>array(array(1,'an')),
    '啽'=>array(array(2,'an')),
    '垵'=>array(array(3,'an'), array(3,'an')),
    '俺'=>array(array(3,'an')),
    '唵'=>array(array(3,'an')),
    '銨'=>array(array(3,'an')),
    '揞'=>array(array(3,'an')),
    '晻'=>array(array(3,'an'), array(4,'an'), array(3,'yan')),
    '犴'=>array(array(4,'an'), array(1,'han')),
    '岸'=>array(array(4,'an')),
    '按'=>array(array(4,'an')),
    '胺'=>array(array(4,'an'), array(4,'e')),
    '案'=>array(array(4,'an')),
    '闇'=>array(array(4,'an')),
    '暗'=>array(array(4,'an')),
    '黯'=>array(array(4,'an')),
    '肮'=>array(array(1,'ang'), array(2,'hang')),
    '卬'=>array(array(2,'ang'), array(3,'yang')),
    '仰'=>array(array(2,'ang'), array(3,'yang')),
    '昂'=>array(array(2,'ang')),
    '枊'=>array(array(4,'ang')),
    '盎'=>array(array(4,'ang')),
    '醠'=>array(array(4,'ang')),
    '凹'=>array(array(1,'ao')),
    '熬'=>array(array(1,'ao'), array(2,'ao')),
    '爊'=>array(array(1,'ao')),
    '敖'=>array(array(2,'ao')),
    '隞'=>array(array(2,'ao')),
    '嶅'=>array(array(2,'ao')),
    '遨'=>array(array(2,'ao')),
    '嗷'=>array(array(2,'ao')),
    '廒'=>array(array(2,'ao')),
    '璈'=>array(array(2,'ao')),
    '獒'=>array(array(2,'ao')),
    '聱'=>array(array(2,'ao')),
    '螯'=>array(array(2,'ao')),
    '翱'=>array(array(2,'ao')),
    '謷'=>array(array(2,'ao')),
    '鼇'=>array(array(2,'ao')),
    '囂'=>array(array(2,'ao'), array(1,'xiao')),
    '鏖'=>array(array(2,'ao')),
    '夭'=>array(array(3,'ao'), array(1,'yao')),
    '芺'=>array(array(3,'ao')),
    '拗'=>array(array(3,'ao'), array(4,'ao'), array(4,'niu')),
    '襖'=>array(array(3,'ao')),
    '媼'=>array(array(3,'ao')),

发表评论

电子邮件地址不会被公开。 必填项已用*标注