trim
Returns a string with whitespace (or other characters) stripped from the beginning and end of string.
Parameters
main.php
Return Values
string
Returns the trimmed string
On success:String with specified characters removed from both ends
On failure:Original string if no characters match
Notes
- By default removes space, tab, newline, carriage return, NULL byte, and vertical tab
- Custom character list can be specified in the second parameter
- Use range notation (..) to specify character ranges like 'a..z'
- Function is binary-safe
Changelog
- Function has been available since PHP 4.0.0
Related Functions
str_replace
StringReplaces all occurrences of search string with replacement string.
replacesanitizeclean
htmlspecialchars
SecurityConverts special characters to HTML entities to prevent XSS attacks and ensure safe HTML output.
securityxsssanitize
filter_var
ValidationFilters a variable with a specified filter, used for validating and sanitizing data.
validatesanitizesecurity
array_values
ArrayReturns all values from an array with numeric keys, effectively reindexing the array.
valuesreindexclean