.
Divya
The trim() function is used to removes whitespace and other predefined characters from both sides of a string in PHP.
<!DOCTYPE html>
<html>
<body>
<?php
$str = "Hello World!";
echo $str . "<br>";
echo trim($str,"Hello"). "<br>";
?>
</body>
</html>
The ltrim() function is used to removes whitespace or other predefined characters from the left side of a string.
<!DOCTYPE html>
<html>
<body>
<?php
$str = "Students Tutorial";
echo $str . "<br>";
echo ltrim($str,"Students"). "<br>";
?>
</body>
</html>
The rtrim() function is used to removes whitespace or other predefined characters from right sides of a string.
<!DOCTYPE html>
<html>
<body>
<?php
$str = "Students Tutorial";
echo $str . "<br>";
echo rtrim($str,"Tutorial"). "<br>";
?>
</body>
</html>
.