Home > Backend Development > PHP Tutorial > ltrim() function in PHP

ltrim() function in PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2023-08-20 22:22:02
forward
2006 people have browsed it

ltrim() function in PHP

#ltrim() function is used to remove spaces or other characters from the beginning of a string.

Syntax

ltrim(str, charlist)
Copy after login

Parameters

  • str − The string to be checked

  • charlist − Specifies the characters to be removed from the string. If the argument is missing, all the following characters

    • ##"\0" − NULL

    • "\ t" − Tab character

    • "

      "

      − Line break character

    • "\x0B" − Vertical tab character

    • "\r" − Carriage return character

    • " " − Ordinary spaces

Return value

ltrim() function returns the modified string .

Example

The following is an example−

Live Demo

<?php
$s = " Welcome!";
echo "Without ltrim = " . $s;
echo "<br>";
echo "With ltrim = " . ltrim($s);
?>
Copy after login

Output

Without ltrim = Welcome!
With ltrim = Welcome!
Copy after login

Example

The following is an example −

Live Demo

<?php
$string = " website";
echo "Welcome to the ".ltrim($string);
?>
Copy after login

Output

Welcome to the website
Copy after login

The above is the detailed content of ltrim() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

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