大网数据广告活动
PHP 语言与运行手册

mb_ltrim · Strip whitespace (or other characters) from the beginning of a string

· 52CE 我爱测

mb_ltrim — Strip whitespace (or other characters) from the beginning of a string

mb_ltrim

(PHP 8 >= 8.4.0)

mb_ltrim — Strip whitespace (or other characters) from the beginning of a string

说明

function 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),普通空格。

  • "\t" (Unicode U+0009),制表符。

  • "\n"(Unicode U+000A),新行(换行)。

  • "\r"(Unicode U+000D),回车。

  • "\0"(Unicode U+0000),NUL 字节。

  • "\v"(Unicode U+000B),垂直制表符。

  • "\f"(Unicode U+000C),换页符。

  • "\u00A0"(Unicode U+00A0),NO-BREAK SPACE。

  • "\u1680"(Unicode U+1680),OGHAM SPACE MARK。

  • "\u2000"(Unicode U+2000),EN QUAD。

  • "\u2001"(Unicode U+2001),EM QUAD。

  • "\u2002"(Unicode U+2002),EN SPACE。

  • "\u2003"(Unicode U+2003),EM SPACE。

  • "\u2004"(Unicode U+2004),THREE-PER-EM SPACE。

  • "\u2005"(Unicode U+2005),FOUR-PER-EM SPACE。

  • "\u2006"(Unicode U+2006),SIX-PER-EM SPACE。

  • "\u2007"(Unicode U+2007),FIGURE SPACE。

  • "\u2008"(Unicode U+2008),PUNCTUATION SPACE。

  • "\u2009"(Unicode U+2009),THIN SPACE。

  • "\u200A"(Unicode U+200A),HAIR SPACE。

  • "\u2028"(Unicode U+2028),LINE SEPARATOR。

  • "\u2029"(Unicode U+2029),PARAGRAPH SEPARATOR。

  • "\u202F"(Unicode U+202F),NARROW NO-BREAK SPACE。

  • "\u205F"(Unicode U+205F),MEDIUM MATHEMATICAL SPACE。

  • "\u3000"(Unicode U+3000),IDEOGRAPHIC SPACE。

  • "\u0085"(Unicode U+0085),NEXT LINE (NEL)。

  • "\u180E"(Unicode U+180E),MONGOLIAN VOWEL SEPARATOR。

参数

string

The input string.

characters

可选,也可以使用 characters 参数指定要删除的字符。只需列出所有需要删除的字符即可。

encoding

encoding 参数为字符编码。如果省略或是 null,则使用内部字符编码。

返回值

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

参见

  • 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() - 删除字符串开头的空白字符(或其他字符)

来源:PHP Documentation Group · 作者与贡献记录 · CC BY 3.0。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
PHP Documentation Group
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。