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?

烟雨青岚
烟雨青岚Original
2020-06-30 15:01:502990browse

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>

Output result:


Without ltrim: Hello World! With ltrim: Hello World!

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!

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