当前位置:网站首页>php字符串的截取方式
php字符串的截取方式
2022-08-02 12:18:00 【m0_67401228】

1、中文截取:mb_substr()。
mb_substr(s t r , str,str,start,l e n g t h , length,length,encoding)
实例
echo mb_substr(‘这个真的很nice’,0,3,‘utf-8’); //输出这个真
2、英文截取:用substr()函数。如果截取的字符串是多个字节,就会出现乱码。
在utf8编码下,由于一个汉字占3个字节。
s t r = ′ h e l l o ′ ; e c h o s u b s t r ( str = 'hello'; echo substr( str=′hello′;echosubstr(str,1,2);//输出el
3、$str[0],将字符串看做字符集合,中文不适用。
$str = ‘hello’;
echo $str[0];//输出h
以上就是php字符串的截取方式,希望对大家有所帮助。
文章转自:php字符串的截取方式_PHP-考高分网 (kaotop.com)[这里是图片002]http://www.kaotop.com/it/729897.html
先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- 【Acunetix-Forgot your password】
- 企业级数据治理工作怎么开展?Datahub这样做
- 力扣209-长度最小的字符串——滑动窗口法
- 1.3快速生成树协议RSTP
- [kali-information collection] (1.9) Metasploit + search engine tool Shodan
- zabbix自动化监控脚本
- 30行代码实现无服务器实时健康码识别--操作手册
- go语言的接口
- 智能图像分析-智能家用电器图像目标检测统计计数检测与识别-艾科瑞特科技(iCREDIT)
- Learning Experience Sharing Seven: YOLOv5 Code Chinese Comments
猜你喜欢

CCF paper conference IEEE how to query all articles of a conference journal

WPF——自定义日历

软件成分分析:手握5大能力守护软件供应链安全

云原生(三十) | Kubernetes篇之应用商店-Helm介绍

自己如何做小程序呢?

Crack detection technology based on deep learning

MD5 detailed explanation (check file integrity)

【Acunetix-忘记密码】

【The 6th Strong Net Cup CTF-Wp】

Drools(8): WorkBench uses
随机推荐
Pod Scheduling Strategy: Affinity, Stain and Stain Tolerance
力扣27-移除元素——简单题
如何搭建威纶通触摸屏与S7-200smart之间无线PPI通信?
软件成分分析:手握5大能力守护软件供应链安全
WPF——自定义日历
Failure Analysis | A SELECT statement crashes MySQL, what happened?
Process finished with exit code 1
Process finished with exit code 1
Manual architecture, Mysql interview 126 questions
Golang map数组按字段分类
MyCat2 introduction and installation and basic use
np.nan, np.isnan, None, pd.isnull, pd.isna finishing and summary
liunx基础命令讲解
Solve the problem of Chinese garbled characters in exporting excel file names
Speed up your programs with bitwise operations
The ex-boyfriend bought chili water and threatened to rob his daughter. Can the woman apply for a personal safety protection order?
力扣58-左旋转字符串
使用kubesphere图形界面创建一个devops的CI/CD流程
SQL function TRIM
SQL函数 $TRANSLATE