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.
#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
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:
<?php $str = 'Demon is an English teacher.17847564092'; $str = rtrim($str,'0..9'); echo $str; //删除末尾多余的数字
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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools
