The trim() function removes whitespace and other predefined characters from both sides of a string.
Related functions:
string trim ( string $str [, string $character_mask = " \t\n\r\0\x0B" ] )
This function returns a string with whitespace stripped from the beginning and end of str. Without the second parameter, trim() will strip these characters:
Parameter | Description |
---|---|
str | The string that will be trimmed. |
character_mask | Optionally, the stripped characters can also be specified using the character_mask parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters. |
The trimmed string.