In PHP, you can use the ltrim() function to remove the tab blank character at the beginning of the string. The syntax is "ltrim(string)"; when only one parameter is passed to the ltrim() function, it is used to specify When you want to check a string, you can delete the whitespace characters (such as spaces, tabs, newlines, etc.) at the beginning of the string.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
In php, you can use ltrim () function to remove the tab space character at the beginning of the string.
ltrim() function removes whitespace characters or other predefined characters at the beginning of a string.
White space characters include: spaces, tabs, newlines and other white space characters.
ltrim() function accepts two parameters:
ltrim(string,charlist)
Description | |
---|---|
string | Required. Specifies the string to check.|
charlist | Optional. Specifies which characters are removed from a string. If this parameter is omitted, all the following characters are removed:
|
Example: Remove the tab blank character (tab character) at the beginning of the string
<?php header('content-type:text/html;charset=utf-8'); $str1 = " Hello World!"; $str2 = "\tHello World!"; echo "处理前的字符串:"; var_dump($str1); var_dump($str2); echo "处理后的字符串:"; var_dump(ltrim($str1)); var_dump(ltrim($str2)); ?>
PHP video tutorial》
The above is the detailed content of How to remove the tab space character at the beginning of the string in php. For more information, please follow other related articles on the PHP Chinese website!