How to use php ltrim function?

青灯夜游
Release: 2023-04-06 18:46:02
Original
3112 people have browsed it

php The ltrim() function is used to delete spaces or other predefined characters on the left side of a string. The syntax is "ltrim(string,charlist)". The parameter string specifies the string to be processed, and the parameter charlist specifies the string to be processed. Which characters are removed from the string; then the modified string is returned.

How to use php ltrim function?

php ltrim function

Function:Remove spaces or other presets on the left side of the string Define characters

Syntax:

ltrim(string,charlist)
Copy after login

Parameters:

● String: Indicates the string that needs to be processed and cannot be omitted.

● charlist optional parameter, specifies which characters to delete from the string, if it is empty, all the following characters will be removed "\0" -- NULL, "\t" -- tab character, "\n" -- line feed, "\x0B" -- vertical tab, "\r" -- carriage return, " " -- space

Return value: Returned Modified string.

Example:

<?php
header("content-type:text/html;charset=utf-8"); 
$i = "     hello world";
echo "未经过处理的".$i."左边是有空格的!";
$j = ltrim($i);
echo "经过处理的".$j."左边是没有空格的!";
?>
Copy after login

Output:

未经过处理的 hello world左边是有空格的!经过处理的hello world左边是没有空格的!
Copy after login

The above is the detailed content of How to use php ltrim function?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template