//mb_substr(str,index,length,type) 切割字串
mb_substr('勇者是魔王',0,2,'utf-8'); //勇者
mb_substr('ABCDE',0,2,'utf-8'); //AB
//substr(str,index,length) 切割字串
substr('勇者是魔王',0,2,'utf-8'); //中文會變為亂碼
substr('ABCDE',0,2); //AB
//strrchr(str,cutStr) 從最後一次出現的cutStr切割
strrchr('勇者H...是魔王.html','.'); //.html
//strstr(str,cutStr) or strchr(str,cutStr) 從第一次出現的cutStr切割
strstr('勇者H...是魔王.html','.'); //...是魔王.html
strstr('勇者H...是魔王.html','h'); //html
//stristr(str,cutStr) 和strstr一樣,但沒有區分大小寫
stristr('勇者H...是魔王.html','h'); //H...是魔王.html
//str_replace(targetStr,newStr,str) 取代字串
str_replace('勇者H','戰士A','勇者H...是魔王.html'); //戰士A...是魔王.html
//str_ireplace(targetStr,newStr,str) 同str_replace一樣,但是不區分大小寫
str_ireplace('勇者h','戰士A','勇者H...是魔王.html'); //戰士A...是魔王.html
//str_pad(str,length,padStr[,padType])
str_pad('50',4,'0'); //5000
str_pad('50',4,'0',STR_PAD_LEFT); //0050
str_pad('50',4,'0',STR_PAD_RIGHT); //5000
str_pad('50',4,'0',STR_PAD_BOTH); //0500
str_pad('50',5,'0',STR_PAD_BOTH); //05000 (沒有兩邊剛好,右邊先補)
Link is http://megull.idv.tw/MegullWorld/php/字串函數/Tags is php,strrchrPush to Create at 2011-05-12 01:04:55, Revise at 2011-05-21 15:51:56