PHP 8.4.0 RC4 available for testing

mb_ltrim

(PHP 8 >= 8.4.0)

mb_ltrimStrip whitespace (or other characters) from the beginning of a string

Description

mb_ltrim(string $string, string $characters = null, string $encoding = null): string

Performs a multi-byte safe ltrim() operation. Strip whitespace (or other characters) from the beginning of a string.

Without the second parameter, mb_ltrim() 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.

Parameters

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

Return Values

This function returns a string with whitespace stripped from the beginning of string.

See Also

  • mb_trim() - Strip whitespace (or other characters) from the beginning and end of a string
  • mb_rtrim() - Strip whitespace (or other characters) from the end of a string
  • ltrim() - Strip whitespace (or other characters) from the beginning of a string
add a note

User Contributed Notes

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