PHP » Strings » ltrim()

Syntax:
string ltrim(string s [, string remove_list])
s
The string.
remove_list
Characters to remove.

Trims whitespace off the left side of a string.

ltrim() works just as trim() but only trims off characters on the left side of the string. The new trimmed string is returned. The optional remove_list parameter can be used to specify which characters should be trimmed off.

Examples

Code:
<pre>
<?php

$s1 = ltrim("   \t  hello there   \n");
$s2 = ltrim("--- hello ---", "-");
printf("[%s]<br>[%s]", $s1, $s2);

?>
</pre>
Output:
[hello there  
]
[ hello ---]
Explanation:

ltrim() is used on two strings, both with and without the use of remove_list.

See Also: