Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议新增获取拼音首字母功能 #1

Closed
LiXunGuan opened this issue Sep 30, 2014 · 6 comments
Closed

建议新增获取拼音首字母功能 #1

LiXunGuan opened this issue Sep 30, 2014 · 6 comments

Comments

@LiXunGuan
Copy link

Pinyin::trans('我们', array('delimiter' => '', 'first' => true));

输出 // wm

@overtrue
Copy link
Owner

OK,没问题,请稍等几日,最近忙于公司项目

在 2014年9月30日,下午5:03,李勋冠 notifications@github.com 写道:

Pinyin::trans('我们', array('delimiter' => '', 'first' => true));

输出 // wm


Reply to this email directly or view it on GitHub #1.

@overtrue
Copy link
Owner

overtrue commented Oct 3, 2014

@LiXunGuan 已经添加获取首字母方法:

include __DIR__ . '/src/Overtrue/Pinyin.php';

$str = "带着希望去旅行,比到达终点更美好";

$pingyin = new Overtrue\Pinyin;

echo $pingyin->firstLetter($str), "\n";
// D Z X W Q L X B D D Z D G M H

echo $pingyin->firstLetter($str, ''), "\n";
//DZXWQLXBDDZDGMH

echo $pingyin->firstLetter($str, '-'), "\n";
//D-Z-X-W-Q-L-X-B-D-D-Z-D-G-M-H

另外修改了一下调用方法, 请查看项目README。

@overtrue overtrue closed this as completed Oct 3, 2014
@LiXunGuan
Copy link
Author

3Q,国庆期间还在coding

@overtrue
Copy link
Owner

overtrue commented Oct 3, 2014

哈哈

在 2014年10月3日,下午5:57,李勋冠 <notifications@github.com mailto:notifications@github.com> 写道:

3Q,国庆期间还在coding


Reply to this email directly or view it on GitHub #1 (comment).

@LiXunGuan
Copy link
Author

如果能搞成静态方法就更好了(PS laravel4用习惯了...强迫症)
Pinyin::firstLetter()
Pinyin::trans()

@overtrue
Copy link
Owner

overtrue commented Oct 4, 2014

@ok。稍等

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants