Python ltrim() function
Python ltrim() function
The ltrim() function in PHP removes whitespace or other predefined characters from the beginning or left side of a string.
The related functions are as follows:
- rtrim() – This function is used to remove whitespace or other predefined characters from the right side of the given string
- trim() - This function is used to remove whitespace or other predefined characters from both sides of the given string.
Syntax
ltrim ( string $str [, string $character_mask ] )
Parameter
str(required)- This parameter specifies the string to check
character_mask(optional)- This parameter specifies which characters to remove from the string.
Return
This function returns a string with whitespace stripped from the beginning of str. If the second parameter is not specified, ltrim() will strip all of the following characters:
- " " - an ordinary space.
- "\t"- a tab.
- "\n" - a new line (line feed).
- "\r"- a carriage return.
- "\0"- the NUL-byte.
- "\x0B" - a vertical tab.
Example 1
Output
Actual string: Hello TutorialandExample! After using the ltrim() function... New String:Hello TutorialandExample!
Example 2
Output
Actual String: Hello World! After using the ltrim() function.. New String: Hello World!
Example 3
Output
Actual String: Hello World! After using the ltrim() function.. New String: Hello World!