php echo substr('hello',1,-2);-2是什么意思 为什么结果是 el

来源:学生作业帮助网 编辑:作业帮 时间:2024/05/03 02:05:29

php echo substr('hello',1,-2);-2是什么意思 为什么结果是 el
php echo substr('hello',1,-2);-2是什么意思 为什么结果是 el

php echo substr('hello',1,-2);-2是什么意思 为什么结果是 el
substr 是截取字符串函数 substr(string,start,length)
h e l l o 对应的针分别为
0 1 2 3 4
-4 -3 -2 -1 0
substr('hello',1,-2); start 是1 所以是从 e 开始截取长度为-2 .是截止到从后面开始数 对应-2 的字母结束 所以是 el