(PHP 8 >= 8.4.0)
mb_trim — Strip whitespace (or other characters) from the beginning and end of a string
Performs a multi-byte safe trim() operation,
and returns a string with whitespace stripped from the
beginning and end of string
.
Without the second parameter,
mb_trim() will strip these characters:
" "
(Unicode U+0020), an ordinary space.
"\t"
(Unicode U+0009), a tab.
"\n"
(Unicode U+000A), a new line (line feed).
"\r"
(Unicode U+000D), a carriage return.
"\0"
(Unicode U+0000), the NUL-byte.
"\v"
(Unicode U+000B), a vertical tab.
"\f"
(Unicode U+000C), a form feed.
"\u00A0"
(Unicode U+00A0), a NO-BREAK SPACE.
"\u1680"
(Unicode U+1680), a OGHAM SPACE MARK.
"\u2000"
(Unicode U+2000), a EN QUAD.
"\u2001"
(Unicode U+2001), a EM QUAD.
"\u2002"
(Unicode U+2002), a EN SPACE.
"\u2003"
(Unicode U+2003), a EM SPACE.
"\u2004"
(Unicode U+2004), a THREE-PER-EM SPACE.
"\u2005"
(Unicode U+2005), a FOUR-PER-EM SPACE.
"\u2006"
(Unicode U+2006), a SIX-PER-EM SPACE.
"\u2007"
(Unicode U+2007), a FIGURE SPACE.
"\u2008"
(Unicode U+2008), a PUNCTUATION SPACE.
"\u2009"
(Unicode U+2009), a THIN SPACE.
"\u200A"
(Unicode U+200A), a HAIR SPACE.
"\u2028"
(Unicode U+2028), a LINE SEPARATOR.
"\u2029"
(Unicode U+2029), a PARAGRAPH SEPARATOR.
"\u202F"
(Unicode U+202F), a NARROW NO-BREAK SPACE.
"\u205F"
(Unicode U+205F), a MEDIUM MATHEMATICAL SPACE.
"\u3000"
(Unicode U+3000), a IDEOGRAPHIC SPACE.
"\u0085"
(Unicode U+0085), a NEXT LINE (NEL).
"\u180E"
(Unicode U+180E), a MONGOLIAN VOWEL SEPARATOR.
string
characters
characters
parameter.
Simply list all characters that need to be stripped.
encoding
The encoding
parameter is the character encoding. If it is omitted or null
, the internal character
encoding value will be used.
The trimmed string.