Home > Backend Development > PHP Tutorial > 生成一个火车站中文名和拼音对应表! 求思路解决办法

生成一个火车站中文名和拼音对应表! 求思路解决办法

WBOY
Release: 2016-06-13 13:42:41
Original
1099 people have browsed it

生成一个火车站中文名和拼音对应表! 求思路
附件一个是全国火车站中文名列表,另一个是中文拼音库,根据这两份资料最后生成一个火车站中文名和拼音对应表(一个一行,一行内用冒号隔开中文和拼音)

注意如果用程序生成后,还要手工淘汰掉出错误的多音字


想问问思路,php数组索引去实现,应该怎么写
分数较少请见谅

------解决方案--------------------

拼音库.txt
吖:a
阿:a
阿:e
啊:a
锕:a
迦:a
嗄:a
哎:ai
哀:ai
......


function foo($v) {
return explode(':', trim($v));
}
foreach(array_map('foo', file('拼音库.txt') as $v)
$dict[$v[0]] = $v[1];

就产生了 汉字为键,拼音为值得数组 $dict

for

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template