How can we remove the white spaces from string in PHP?

There are three functions in PHP to remove the white spaces from the string.
trim()-It removes whitespaces from the left and right side of the string.
ltrim()-It removes whitespaces from the left side of the string.
rtrim()-It removes whitespaces from the right side of the string.

Example:


Learn more about the similar topics?
Tutorials
  • No Content Found.
  • Interview Questions & Answers
  • No Content Found.
  • Exercises & Assignments
  • No Content Found.