Home  >  Article  >  Backend Development  >  What are the functions in php that can remove spaces?

What are the functions in php that can remove spaces?

王林
王林Original
2020-08-19 16:11:042915browse

The functions in php that can remove spaces are: 1. ltrim(), this function can remove spaces at the beginning of a string; 2. rtrim(), this function can remove spaces at the end of a string; 3. , trim(), this function can remove spaces at the beginning and end of a string.

What are the functions in php that can remove spaces?

#ltrim function removes spaces or other characters at the beginning of a string.

(Recommended tutorial: php graphic tutorial)

Syntax:

string ltrim(string $str [,string $charlist])

Description: charlist specifies which characters to delete from the string. If this parameter is omitted by default, all the following characters

What are the functions in php that can remove spaces?

are removed. Example:

$str = "\n\n\t\tABC\t\t";
echo ltrim($str);
//输出后,ABC前面的空白就没有了

rtrim function removes spaces or other characters at the end of a string.

(Video tutorial recommendation: php video tutorial)

Syntax:

string rtrim(string $str[,string $charlist])

trim function to delete spaces or other spaces at the beginning and end of a string character.

Grammar:

string trim(string $str[,string $charlist])

Example:


The above is the detailed content of What are the functions in php that can remove spaces?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn