Initial commit: 小众厨房项目代码

Co-authored-by: Cursor <cursoragent@cursor.com>
这个提交包含在:
可乐加冰
2026-09-23 17:04:10 +08:00
当前提交 f7d3d7d1bd
共有 1761 个文件被更改,包括 453668 次插入 和 0 次删除

36
extend/fast/Pinyin.php 普通文件
查看文件

@@ -0,0 +1,36 @@
<?php
namespace fast;
/**
* 中文转拼音类
*/
class Pinyin
{
/**
* 获取文字的拼音
* @param string $chinese 中文汉字
* @param boolean $onlyfirst 是否只返回拼音首字母
* @param string $delimiter 分隔符
* @param bool $ucfirst 是否首字母大写
* @return string
*/
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;
}
}