当前位置:网站首页>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开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦
边栏推荐
- Likou 209 - String with the Minimum Length - Sliding Window Method
- SQL函数 $TRANSLATE
- QAbstractScrollArea、QScrollArea
- 力扣704-二分查找
- 今日睡眠质量记录85分
- go语言的接口
- After Effects 教程,如何在 After Effects 中对蒙版进行动画绘制?
- Hand rolled architecture, 41 Redis interview asked
- 力扣977-有序数组的平方——暴力法&双指针法
- Pod Scheduling Strategy: Affinity, Stain and Stain Tolerance
猜你喜欢

使用kubesphere图形界面创建一个devops的CI/CD流程

DTG-SSOD:最新半监督检测框架,Dense Teacher(附论文下载)

Likou 704 - binary search

Distributed current limiting, hand & redisson implementation

面积曲线AUC(area under curve)

受邀出席Rust开发者大会|Rust如何助力量化高频交易?

CCF论文会议 IEEE 如何查询某个会议期刊的所有文章

np.nan, np.isnan, None, pd.isnull, pd.isna 整理与小结

Likou 35 - search for insertion position - binary search

MyCat2 introduction and installation and basic use
随机推荐
SuperSlide系列之轮播图
Free Chinese-English Translation Software - Automatic Batch Chinese-English Translation Software Recommended Daquan
力扣27-移除元素——简单题
Likou 58 - Left Rotation String
Create an application operation process using the kubesphere GUI
Pytorch 占用cpu资源过多
Pod Scheduling Strategy: Affinity, Stain and Stain Tolerance
自己如何做小程序呢?
Process finished with exit code 1
力扣35-搜索插入位置——二分查找
doc2vec和word2vec(zigbee简介及应用)
数据湖(二):什么是Hudi
SQL function TRIM
半夜赶工制作简报的我好想说 : 确定了,最终稿就是这样
darknet训练yolov4模型
Create your own app applet ecosystem with applet containers
How to connect TDengine through DBeaver?
匹配滤波(四种滤波器的幅频特性)
Metaverse "Drummer" Unity: Crazy expansion, suspense still exists
【MySQL】多表联合查询、连接查询、子查询「建议收藏」