Skip to content

Commit 5d98b7e

Browse files
committed
First letters bugfix #27
1 parent bf03378 commit 5d98b7e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Pinyin/Pinyin.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ public static function trans($string, array $settings = array())
139139
*/
140140
public static function letter($string, array $settings = array())
141141
{
142+
$settings = array_merge($settings, array('accent' => false, 'only_chinese' => true));
143+
142144
$parsed = self::parse($string, $settings);
143145

144146
return $parsed['letter'];
@@ -212,8 +214,6 @@ public static function appends(array $appends)
212214
*/
213215
protected function getFirstLetters($pinyin, $settings)
214216
{
215-
$pinyin = preg_replace('/\s?[a-zA-Z]+(\b|\s)/', '', $pinyin);
216-
217217
$letterCase = $settings['uppercase'] ? 'strtoupper' : 'strtolower';
218218

219219
$letters = array();

0 commit comments

Comments
 (0)