substr 可以幫我們切割字串並依指定的回傳其中一段。
語法:
substr(string,start,length)
其中一定要有 string 跟 start,length 如果沒有寫的話則會回傳剩餘的內容,start 可以正的也可以負的,負數的話就是從後面算過來。
例子
echo substr("Hello world!",6);
//輸出:world!
echo substr("Hello world!",6, 3);
//輸出:wor
echo substr("Hello world!",-3);
//輸出 ld!