Remove whitespace or other characters from the start and end of a string with trim().
Source Code
$text = " Hello World! ";
$trimmed = trim($text);
echo "Untrimmed: "$text" Trimmed: "$trimmed""; // Outputs: Untrimmed: " Hello World! " Trimmed: "Hello World!"