Home > Backend Development > PHP Problem > What is the function in php to remove leading spaces from a string?

What is the function in php to remove leading spaces from a string?

烟雨青岚
Release: 2023-03-01 19:12:01
Original
2995 people have browsed it

The function is: Ltrim(). The function of the ltrim() function is to remove spaces or other predefined characters from the left side of the string; its syntax is "ltrim(string,charlist)"; the parameter string represents the string to be converted; the parameter charlist represents what to delete from the string character.

What is the function in php to remove leading spaces from a string?

The function Ltrim() is to delete the starting spaces of the string.

Use to delete the starting and trailing spaces of the string. FunctionTrim().

The Rtrim() function removes trailing spaces from the string.

The Lcase() function converts uppercase letters in a string into lowercase letters.

ltrim() function removes spaces or other predefined characters from the left side of a string.

Syntax: ltrim(string,charlist)

What is the function in php to remove leading spaces from a string?

##Example:

<html> 
<body> 
<?php
$str = " Hello World!";
echo "Without ltrim: " . $str;
echo "<br />";
echo "With ltrim: " . ltrim($str);
?> 
<body>
<html>
Copy after login

Output result:


Without ltrim: Hello World! With ltrim: Hello World!
Copy after login

Recommended tutorial: "

php tutorial"

The above is the detailed content of What is the function in php to remove leading spaces from a string?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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