phpday 2025 - Call For Papers

mb_trim

(PHP 8 >= 8.4.0)

mb_trimStrip whitespace (or other characters) from the beginning and end of a string

Açıklama

mb_trim(string $string, ?string $characters = null, ?string $encoding = null): 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.

Bağımsız Değişkenler

string
The string that will be trimmed.
characters
Optionally, the stripped characters can also be specified using the characters parameter. Simply list all characters that need to be stripped.
encoding

kodlama bağımsız değişkeninde karakter kodlaması belirtilir. Belirtilmediği takdirde veya null ise dahili karakter kodlaması kullanılır.

Dönen Değerler

The trimmed string.

Ayrıca Bakınız

  • mb_ltrim() - Strip whitespace (or other characters) from the beginning of a string
  • mb_rtrim() - Strip whitespace (or other characters) from the end of a string
  • trim() - Dizgenin başındaki ve sonundaki boşlukları (veya diğer karakterleri) budar
add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top