Home > Article > Backend Development > How to use php ltrim function?
php The ltrim() function is used to delete spaces or other predefined characters on the left side of a string. The syntax is "ltrim(string,charlist)". The parameter string specifies the string to be processed, and the parameter charlist specifies the string to be processed. Which characters are removed from the string; then the modified string is returned.
php ltrim function
Function:Remove spaces or other presets on the left side of the string Define characters
Syntax:
ltrim(string,charlist)
Parameters:
● String: Indicates the string that needs to be processed and cannot be omitted.
● charlist optional parameter, specifies which characters to delete from the string, if it is empty, all the following characters will be removed "\0" -- NULL, "\t" -- tab character, "\n" -- line feed, "\x0B" -- vertical tab, "\r" -- carriage return, " " -- space
Return value: Returned Modified string.
Example:
<?php header("content-type:text/html;charset=utf-8"); $i = " hello world"; echo "未经过处理的".$i."左边是有空格的!"; $j = ltrim($i); echo "经过处理的".$j."左边是没有空格的!"; ?>
Output:
未经过处理的 hello world左边是有空格的!经过处理的hello world左边是没有空格的!
The above is the detailed content of How to use php ltrim function?. For more information, please follow other related articles on the PHP Chinese website!