PHP 新手教學 String | trim的使用說明

Table of Contents

Table of Contents

trim

刪除字串開頭與末端的空白符號或是其他設定的符號(character_mask)。

trim ( string $str [, string $character_mask ] ) : string

Example:

$test1 = "  hi, this is cyublog  ";
print_r(trim($test1));

$test2 = "~~hi, this is cyublog~~ ";
print_r(trim($test2, "~"));

Output:

// trim($test1):
hi, this is cyublog

// trim($test2):
hi, this is cyublog

相關函數