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

Table of Contents

Table of Contents

ltrim

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

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

Example:

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

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

Output:

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

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

相關函數