|
|
Tutorials » Php »
|
Topic |
What is trim Function?
|
|
Explanation |
|
In PHP, this function is used strip whitespace or other characters from the beginning and end of a string.
Syntax:
trim(string,charlist)
In the above syntax given "string" is the input to strip characters, "charlist" specify the following characters to remove
"\0","\t","\n","\x0B","\r"," ",if none is specified all the characters are removed.
Example:
<?php
$text = "\t\tThese are a few words :) ... ";
echo "Without trim:".$text;
echo ">br/<";
echo "With trim:".trim($text);
?>
Result:
Without trim: These are a few words :) ...
With trim: These are a few words :) ...
In the above example the tab spaces,white spaces are removed from the string and displayed.
|
|
A Note |
Learn PHP programming language tutorial with simple and neat example. Hope you enjoy this free tutorial.
Do give us your valuable feedback and suggestions on this online tutorial. This is a Copyright Content.
|
|
|
|