php trim spaces from start and end of string code example Example: remove space from start and end of string in php $trimmed = trim($text); var_dump($trimmed);