Easy Tutorial
❮ Pdo Getavailabledrivers Func Array Usort ❯

PHP ltrim() Function

PHP String Reference Manual

Example

Remove characters from the left side of a string:


Definition and Usage

The ltrim() function removes whitespace characters or other predefined characters from the left side of a string.

Related functions:


Syntax

Parameter Description
string Required. Specifies the string to check.
charlist Optional. Specifies which characters to remove from the string. If omitted, all of the following characters are removed: "\0" - NULL<br> "\t" - Tab<br> "\n" - Newline<br> "\x0B" - Vertical tab<br> "\r" - Carriage return<br> " " - Space

Technical Details

Return Value: Returns the modified string.
PHP Version: 4+
--- ---
Changelog: The charlist parameter was added in PHP 4.1.
--- ---

More Examples

Example 1

Remove spaces from the left side of a string:

HTML output of the above code (view source):

Browser output of the above code:

Example 2

Remove newline characters (\n) from the left side of a string:

HTML output of the above code (view source):

Browser output of the above code:


❮ Pdo Getavailabledrivers Func Array Usort ❯