Why we use trim() Function in php ?
The trim() function mainly use for removes the spaces from the beginning and the end of the string.
trim() function will divest and control characters such as :
" " an ordinary space.
"\t" a tab.
"\n" a new line
"\r" a carriage return.
You can see below example of trim() function.
<?php
$TitleNamae = "Jurasic World!";
//here $TitleNamae variable
echo $TitleNamae . "<br>";
//echo full string
echo trim($TitleNamae,"Jud!");
//here call trim() to remove beginning and the end of the string
//Jurasic World!( "Ju" in "Jurasic" and "d!" in "World!")
?>
So when we will echo the output then,
Output will come
Jurasic World!
rasic Worl
0 Comment(s)