(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), un espacio ordinario.
"\t"
(Unicode U+0009), un tabulador.
"\n"
(Unicode U+000A), una nueva línea (line feed).
"\r"
(Unicode U+000D), un retorno de carro.
"\0"
(Unicode U+0000), el byte NULL
.
"\v"
(Unicode U+000B), un tabulador vertical.
"\f"
(Unicode U+000C), un salto de página.
"\u00A0"
(Unicode U+00A0), un ESPACIO SIN SEPARACIÓN (NO-BREAK SPACE).
"\u1680"
(Unicode U+1680), una MARCA DE ESPACIO OGHAMA.
"\u2000"
(Unicode U+2000), un CUADRATÍN.
"\u2001"
(Unicode U+2001), un CUADRATÓN.
"\u2002"
(Unicode U+2002), un espacio EN.
"\u2003"
(Unicode U+2003), a espacio EM.
"\u2004"
(Unicode U+2004), un espacio DE TRES POR EM.
"\u2005"
(Unicode U+2005), un espacio DE CUATRO POR EM.
"\u2006"
(Unicode U+2006), un espacio DE SEIS POR EM.
"\u2007"
(Unicode U+2007), un espacio DE CIFRA.
"\u2008"
(Unicode U+2008), un espacio DE PUNTUACIÓN.
"\u2009"
(Unicode U+2009), un espacio FINO.
"\u200A"
(Unicode U+200A), un espacio CABELLO.
"\u2028"
(Unicode U+2028), un SEPARADOR DE LÍNEA.
"\u2029"
(Unicode U+2029), un SEPARADOR DE PÁRRAFO.
"\u202F"
(Unicode U+202F), un espacio ESTRECHO SIN SEPARACIÓN.
"\u205F"
(Unicode U+205F), un espacio MATEMÁTICO MEDIO.
"\u3000"
(Unicode U+3000), un espacio IDEOGRÁFICO.
"\u0085"
(Unicode U+0085), una nueva línea (NEL).
"\u180E"
(Unicode U+180E), un separador de VOCALES MONGOL.
string
characters
characters
.
Simplemente enumere todos los caracteres que necesitan ser eliminados.
encoding
El parámetro encoding
es la codificación de caracteres. Si es omitido o null
, será usado el valor de la
codificación de caracteres interna.
The trimmed string.