Home > Article > Backend Development > What is the function in php to remove leading spaces from a string?
The function is: Ltrim(). The function of the ltrim() function is to remove spaces or other predefined characters from the left side of the string; its syntax is "ltrim(string,charlist)"; the parameter string represents the string to be converted; the parameter charlist represents what to delete from the string character.
The function Ltrim() is to delete the starting spaces of the string.
Use to delete the starting and trailing spaces of the string. FunctionTrim().
The Rtrim() function removes trailing spaces from the string.
The Lcase() function converts uppercase letters in a string into lowercase letters.
ltrim() function removes spaces or other predefined characters from the left side of a string.
Syntax: ltrim(string,charlist)
##Example:<html> <body> <?php $str = " Hello World!"; echo "Without ltrim: " . $str; echo "<br />"; echo "With ltrim: " . ltrim($str); ?> <body> <html>Output result:
Without ltrim: Hello World! With ltrim: Hello World!Recommended tutorial: "
php tutorial"
The above is the detailed content of What is the function in php to remove leading spaces from a string?. For more information, please follow other related articles on the PHP Chinese website!