php remove whitespace from start and end of string code example
Example 1: remove every whitespace php
$string = preg_replace('/\s+/', '', $string);
Example 2: php remove space before and after string
$words = ' my words ';
$words = trim($words);
var_dump($words);
// string(8) "my words"