Trims whitespace off a string.
This function returns a new string with the whitespace trimmed off both sides of the input string. By default, this includes tabs, new line characters, and null. The optional remove_list parameter can be used to specify which characters should be trimmed off.
<?php
$s1 = trim(" \t hello there \n");
$s2 = trim("--- hello ---", "-");
printf("[%s]<br>[%s]", $s1, $s2);
?>
[hello there]
[ hello ]
trim() is used on two strings, both with and without the use of remove_list. Note that the spaces are left in $s2.