The
trim() string function in PHP will remove whitespace or specified characters from the end and beginning of a string. This function can take up to two parameters. If only fed one parameter it will remove whitespace from both ends. If fed a second parameter(a specified character list), it will remove the specified characters from both ends of the string.
<?php
$myString = "only going to the zoo";
$myString = trim($myString, "o");
echo $myString;
echo "<hr />";
$myString = trim($myString, "noz e");
echo $myString;
?>
nly going to the z
ly going to th