Loading…

What is TRIM function in PHP?

trim() removes all blank spaces or whitespace or other (specified) characters from both sides of a string.

$var = “ Best Interview Questions ”;
echo $var;

Types:
  • ltrim() – It removes whitespace/other specified characters from the left side of a string.
  • rtrim() - It removes whitespace/other specified characters from the right side of a string.

Example

                                        

$var = “Best Interview Questions”;

ltrim(“Best”, $var);
rtrim(“Questions”, $var);

 

Suggest An Answer

No suggestions avaliable!

Latest post from PHP Strings

Ask Question