LTrim
- (PHP 4, PHP 5, PHP 7)
- Ltrim-strip whitespace (or other characters) from the beginning of a string
- ltrim-Delete whitespace characters (or other characters) at the beginning of a string
Description
string ltrim ( string $str [, string $character_mask ] )//Strip whitespace (or other characters) from the beginning of a string.//删除字符串开头的空白字符(或其他字符)
Parametersstr
- The input string.
- The input string.
Character_mask
- You can also specify the characters your want to strip, by means of the Character_mask parameter. Simply list all characters so want to be stripped. With.. You can specify a range of characters.
- With the parameter character_mask, you can also specify the characters you want to delete and simply list all the characters you want to delete. Use: To specify the range of characters.
Return Values
- This function returns a string with whitespace stripped from the beginning of Str. Without the second parameter, LTrim () would strip these characters:
- The function returns a string that removes the leftmost white space character of Str. If you do not use the second argument, LTrim () deletes only the following characters:
- "" (ASCII (0x20)), an ordinary space. Plain white space character.
- "\ T" (ASCII 9 (0x09)), a tab. tab.
- "\ n" (ASCII (0x0A)), a new line feed. NewLine characters.
- "\ R" (ASCII (0x0D)), a carriage return. Carriage return.
- "\" (ASCII 0 (0x00)), the Nul-byte.nul null byte character.
- "\x0b" (ASCII One (0x0B)), a vertical tab. Vertical tab.
Examples
<?php/*** Created by Phpstorm.* User:zhangrongxiang* DATE:2018/3/4* Time: PM 4:37 *///ltrim-Delete whitespace characters (or other characters) at the beginning of a string$hello="Hello World";//hello WorldEcho LTrim( $hello ).Php_eol;//ello WorldEcho LTrim( $hello, ' H ' ).Php_eol;//llo WorldEcho LTrim( $hello, ' EH ' ).Php_eol;$text="\t\tThese is a few words:) ... ";//These is a few words:) ...Echo $text.Php_eol;//these is a few words:) ...Echo LTrim( $text ).Php_eol;//these is a few words:) ...Echo LTrim( $text, "\ t" ).Php_eol;//These is a few words:) ...Echo LTrim( $text, ' \ t ' ).Php_eol;$binary="\x09Example String\x0a";//Example string//Echo $binary.Php_eol;//example String//Echo LTrim( $binary ).Php_eol;//example String//Echo LTrim( $binary, "\x00..\x1f" ).Php_eol;
See
The LTrim () function of the PHP string is used