Table of Contents

Syntax

string ltrim(string $source [, string $trimCharacters])

(PHP 4, PHP 5)

$source The source string from which characters should be stripped.
$trimCharacters A list of characters which should be stripped (optional).
RETURNS The source string with characters stripped from the left side only.

What it Does

Trims whitespace characters from the left side (beginning) of the $source string. The user may specify a list of characters to strip by specifying the optional $trimCharacters parameter. If not specified, the function will only strip the whitespace characters listed below:

” ” A space character.
“\t” A tab character.
“\n” A newline character.
“\r” A carriage return character.
“\x0b” A vertical tab character.

Example

// trim whitespace from the left of a string
$input = " 	\t\r\n	Santa Clause";
$results = array($input, ltrim($input));
print_r($results);
// prints:
// array(
// 	[0] -> " 	\t\r\n	Santa Clause",
// 	[1] -> "Santa Clause"
// )