mb_trim

(PHP 8 >= 8.4.0)

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

Опис

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, trim() will strip these characters:

  • " ": символ ASCII SP 0x20, звичайний пропуск.
  • "\t": символ ASCII HT 0x09, табуляція.
  • "\n": символ ASCII LF 0x0A, новий рядок.
  • "\r": символ ASCII CR 0x0D, повернення каретки.
  • "\0": символ ASCII NUL 0x00, NUL-байт.
  • "\v": символ ASCII VT 0x0B, вертикальна табуляція.

Параметри

string
The string that will be trimmed.
characters
Символи, що треба вилучити, можна вказати за допомогою необов'язкового параметра characters. Необхідно просто записати туди усі потрібні символи. За допомогою .. можна задати діапазон символів за зростанням.
encoding
The string encoding.

Значення, що повертаються

The trimmed string.

Прогляньте також

  • 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() - Strip whitespace (or other characters) from the beginning and end of a string