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

Table of Contents

Table of Contents

rtrim

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

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

Example:

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

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

Output:

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

// rtrim($test2):
~~hi, this is cyublog

相關函數