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:
<?php
$string=" Interview Question and Answers for your help ";
$var1=trim($string);
echo $var1;
$var2=ltrim($string);
echo $var2;
$var3=rtrim($string);
echo $var3;
?>
Learn more about the similar topics:
Tutorials |
No Content Found. |
Exercises & Assignments |
No Content Found. |
Interview Questions & Answers |
No Content Found. |