Javatpoint Logo
Javatpoint Logo

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.


Parameter Description Required/Optional
String Specify the string to check. Required
charlist Specify character to remove from the string.
  • "\0" : NULL
  • "\t" : tab
  • "\n" : new line
  • "\x0B" : vertical tab
  • "\r" : carriage return
  • " " : ordinary white space

Example 1


Without ltrim() Function: Hello PHP!
With ltrim() function : Hello PHP!

Example 2


Without ltrim() Function: Hello PHP Javatpoint!
With ltrim() function: Hello PHP Javatpoint!

Example 3


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

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA