1、chunk_split()函數
把字符串切割成更小的部分
語法
chunk_split(string,length,end);
代碼示例
php
str=”holleword”; echochunksplit(str,2,’,’).”
“;
echochunk_split(str,3,’,’).” “; ?> 2、explode()函數 使用一個字符串切割另一個字符串,並回來由字符串組成的數組 語法 explode(“切割符”,string,limit)
代碼示例
php
str=”one,two,three,apple,blue”; printr(explode(“,”,str,2));
print_r(explode(“t”,str,5)); 3、implode()函數 回來一個由數組元素組合成的字符串 語法 implode(“元素之間放置的內容”,array); 代碼示例 php str=array(‘holle’,’jack’,’welcome’,’to’,’city’);
echoimplode(“”,str); ?> 4、md5()函數 md5加密 語法 MD5(string); 代碼示例 php str=”helloworld”;
echomd5(KaTeX parse error: Expected 'EOF', got '#' at position 12: str);
?>c#̲獲取文字全拼音
5、str…str=”helloPHP”;
echostrlen(str); ?> 6、strrepeat()函數 回來重復後的字符串 語法 strrepeat(string,int); 代碼示例 php str=”-+-/”;
echostr_repeat(str,5); ?> 7、strreplace()函數 該函數回來替換後的數組或者字符串 語法 strreplace(search,replace,string,int) 代碼示例 php str=”helloworld”;
str1=strreplace(“l”,””,str,count); echocount;
?>
8、substr_count()函數
統考某個子串的呈現的頻率
語法
substr_count(str,needel,start,length)
代碼示例
php
str=”helloworld”; echosubstrcount(str,’o’),’
‘;
?>
9、str_pad()
將字符串填充到指定長度
語法
str_pad(string,length,”填充字符”)
代碼示例
php
echostr_pad(‘hello’,10,’*+’);
?>
10、wordwrap()函數
打斷字符串爲指定數量的字串
語法
wordwrap(stringstr[,intwidth=75[,stringKaTeX parse error: Undefined control sequence: \n at position 8: break=“\̲n̲”[,boolcut=FALSE]]])
代碼示例
php
str=”helloworld”; echowordwrap(str,5,”——”,true);
?>
11、ucfirst()
將字符串的首字母轉換爲大寫
語法
ucfirst(string)
代碼示例
php
str=”helloworld”; echoucfirst(str);
?>