Javatpoint Logo
Javatpoint Logo

PHP string trim() function

PHP string trim() function is in-built function. It is used to strip whitespace from the beginning and end of a string or both side of a string.


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

Example 1


Your string is: Hello PHP!
By using trim() function :llo PHP

Example 2


Without trim() function: Hello Javatpoint! 
With trim() function: Hello Javatpoint!

Example 3


Without trim() function: Hello Javatpoint 
With trim() function:Hello Javatpoint

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