截取一个子串
str strlen(str s,int st,int len);
//s: 原字符串
//st:起始位置,负数相当于strlen+st
//len:截取长度,负数相当于strlen+len
示例
str s="hello world";
echo(substr(s,0,3));echo("\r\n"); //hel
echo(substr(s,2,3));echo("\r\n"); //llo
echo(substr(s,0,-1));echo("\r\n"); //hello worl
echo(substr(s,-1,1));echo("\r\n"); //d
echo(substr(s,-1,-1));echo("\r\n"); //d
注意
- 字符采用GBK内码规范,因此一个汉字占两个字符;