How to use trim in PHP

In this article I will explain how trim function can be used in PHP.
  • 1635

trim() Function

This function removes spaces and other predefined characters from both sides of a string.

Syntax

trim(string,charlist)

Example

<html>
<body>
<?php
$str = " Hello Swati! ";
echo "Without trim: " . $str;
echo "<br />";
echo "With trim: " . trim($str);
?>
</body>
</html>

 

Output
Trim-php.jpg

You may also want to read these related articles Click here

Ask Your Question

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.