函數結構:app
string trim ( string $str [, string $character_mask = " \t\n\r\0\x0B" ] )
第一個參數是咱要處理的字符串,第二個參數是要排除的字符(默認 \t\n\r\0\x0B)函數
函數結構:oop
mixed str_replace ( mixed $search , mixed $replace , mixed $subject [, int &$count ] )
解釋起來太麻煩,咱們來看實例:this
$str1 = str_replace('%name%', 'LargerK', 'my name is %name%'); echo $str1; // 輸出 my name is LargerK
$str1 = str_replace(['s', 'a', 't'], '111', 'this is an apple'); echo $str1; // 輸出 111hi111 i111 111n 111pple
$str1 = str_replace(["KFC", "可樂", "薯條"], ["披薩", "酥皮湯", "西冷牛排"], '我想吃KFC 點個薯條和可樂'); echo $str1; // 我想吃披薩 點個西冷牛排和酥皮湯
$count = 0; $str1 = str_replace("oo", "~~", "ooop good... so cool", $count); echo $str1 . "<br />"; // 輸出~~op g~~d... so c~~l echo $count; // 輸出 3
int strlen ( string $string )
echo strlen('hello k'); // 7