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 Available!