123456789101112131415161718192021222324252627282930313233343536 |
- <?php
- namespace fast;
- class Pinyin
- {
-
- public static function get($chinese, $onlyfirst = false, $delimiter = '', $ucfirst = false)
- {
- $pinyin = new \Overtrue\Pinyin\Pinyin();
- if ($onlyfirst) {
- $result = $pinyin->abbr($chinese, $delimiter);
- } else {
- $result = $pinyin->permalink($chinese, $delimiter);
- }
- if ($ucfirst) {
- $pinyinArr = explode($delimiter, $result);
- $result = implode($delimiter, array_map('ucfirst', $pinyinArr));
- }
- return $result;
- }
- }
|