117
PHP string ltrim() function
PHP string ltrim() function is predefined function. It is often used to remove whitespace from both sides of a string or other character from the left side of a string.
Syntax:
Parameter | Description | Required/Optional |
---|---|---|
String | Specify the string to check. | Required |
charlist | Specify character to remove from the string.
| Optional |
Example 1
Output:
Without ltrim() Function: Hello PHP! With ltrim() function : Hello PHP!
Example 2
Output:
Without ltrim() Function: Hello PHP TutorAspire! With ltrim() function: Hello PHP TutorAspire!
Example 3
Output:
Without ltrim(): Hello World! With ltrim: Hello World!
Note: To remove newlines from the left side of a string then we can use (n):
Next TopicPHP String