PinyinHelper.php 290 B

123456789101112131415
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Tools;
  4. use Overtrue\Pinyin\Pinyin;
  5. class PinyinHelper
  6. {
  7. public static function getFirstLetter(string $string): string
  8. {
  9. $pinyin = new Pinyin();
  10. return strtolower(implode('', $pinyin->abbr($string)->toArray()));
  11. }
  12. }