Chinese to pinyin translator based on CC-CEDICT.
$py = new Pinyin('./dict/cedict_ts.u8');
echo $py->trans('带着希望去旅行,比到达终点更美好');
// dài zhe xī wàng qu lǚ xíng , bǐ dào dá zhōng diǎn gèng měi hǎo
delimiter
Separator between each pinyin, default is a space ' '.accent
Whether the output tone.
<?php
$setting = [
'delimiter' => '-',
];
$py = new Pinyin('./dict/cedict_ts.u8', $setting);
echo $py->trans('带着希望去旅行,比到达终点更美好');
// dài-zhe-xī-wàng-qu-lǚ-xíng-bǐ-dào-dá-zhōng-diǎn-gèng-měi-hǎo
<?php
$setting = [
'delimiter' => '-',
'accent' => false,
];
$py = new Pinyin('./dict/cedict_ts.u8', $setting);
echo $py->trans('带着希望去旅行,比到达终点更美好');
// dai-zhe-xi-wang-qu-lu-xing-bi-dao-da-zhong-dian-geng-mei-hao
$setting = [
'accent' => false,
];
$py = new Pinyin('./dict/cedict_ts.u8', $setting);
echo $py->trans('带着希望去旅行,比到达终点更美好');
// dai zhe xi wang qu lu xing bi dao da zhong dian geng mei hao
MIT