substr() 函數返回字符串的一部分。
注:如果 start 參數是負數且 length 小于或等于 start,則 length 為 0。
substr(string,start,length)
string 必需。規定要返回其中一部分的字符串。
start 必需。規定在字符串的何處開始。
正數 - 在字符串的指定位置開始
負數 - 在從字符串結尾的指定位置開始
0 - 在字符串中的第一個字符處開始
length 可選。規定要返回的字符串長度。默認是直到字符串的結尾。
正數 - 從 start 參數所在的位置返回
負數 - 從字符串末端返回
返回值: 返回字符串的提取部分,如果失敗則返回 FALSE,或者返回一個空字符串。
<?phpecho substr("this is tom",10)."<br>";echo substr("this is tom",1)."<br>";echo substr("this is tom",3)."<br>";echo substr("this is tom",7)."<br>"; echo substr("this is tom",-1)."<br>";echo substr("this is tom",-10)."<br>";echo substr("this is tom",-8)."<br>";echo substr("this is tom",-4)."<br>";?>
本文發布于:2023-02-28 20:03:00,感謝您對本站的認可!
本文鏈接:http://www.newhan.cn/zhishi/a/167765248575148.html
版權聲明:本站內容均來自互聯網,僅供演示用,請勿用于商業和其他非法用途。如果侵犯了您的權益請與我們聯系,我們將在24小時內刪除。
本文word下載地址:php substr(php substr.doc
本文 PDF 下載地址:php substr(php substr.pdf
| 留言與評論(共有 0 條評論) |