0
点赞
收藏
分享

微信扫一扫

输入字符串,返回字符串前三字母

花海书香 2023-01-12 阅读 121


//函数,输入字符串,返回字符串前三字母
public function getStoreName($str){
$one = mb_substr($str, 0, 1, 'utf-8');
$two = mb_substr($str, 1, 2, 'utf-8');
$three = mb_substr($str, 2, 3, 'utf-8');

if(preg_match('/^[\x7f-\xff]+$/', $one)){
$one = getFirstCharter($one);
}
if(preg_match('/^[\x7f-\xff]+$/', $two)){
$two = getFirstCharter($two);
}
if(preg_match('/^[\x7f-\xff]+$/', $three)){
$three = getFirstCharter($three);
}

return $one.$two.$three;

}

好像有点问题

举报

相关推荐

0 条评论