packagist: https://packagist.org/packages/overtrue/pinyin
github: https://github.com/overtrue/pinyin
安装
composer require overtrue/pinyin
使用示例
use Overtrue\Pinyin\Pinyin; $pinyin = new Pinyin(); // 默认 $text = '北京市'; $pinyin->convert($text);
输出
array(3) { [0]=> string(3) "bei" [1]=> string(4) "jing" [2]=> string(3) "shi" }