PHP Programing language

trim() Functions in PHP
Previous Home Next

trim()

This function removes the whitespaces from both start and the end of the string.

Syntax :
trim("string");

Example:

<?php
$str = "Gud Morning!";
echo $str . "<br>";
echo trim($str,"Gug!");
?>

 

Output:

Gud Morning!
d Mornin

ltrim()

This function removes the whitespaces from the left part of the string.

Syntax :
ltrim("string");

Example:

<?php
$str = "Gud Morning..!!!";
echo ltrim($str,"Gud");
?>

Output:

Morning..!!!

rtrim()

This function removes the whitespaces from the right part of the string.

Syntax :
rtrim("string");

Example:

<?php
$str = "Gud Morning";
echo rtrim($str,"Morning");
?>

Output:

Gud

Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Name:
eMail:
Comment / Feedback: