Home  >  Article  >  Backend Development  >  How to remove the symbol on the left side of a character in php

How to remove the symbol on the left side of a character in php

WBOY
WBOYOriginal
2022-02-14 17:56:053322browse

In PHP, you can use the ltrim() function to remove the symbol on the left side of the character. The function of this function is to remove the blank characters or other predefined characters on the left side of the string. You only need to set the parameter to the one specified on the left. The symbol is enough, and the syntax is "ltrim (the string of characters that need to be removed, the symbol on the left that needs to be removed)".

How to remove the symbol on the left side of a character in php

The operating environment of this tutorial: windows10 system, PHP7.1 version, DELL G3 computer

How to remove the symbol on the left side of the character in php

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

Related functions:

  • rtrim() - Removes whitespace characters or other predefined characters on the right side of a string.

  • trim() - Removes whitespace or other predefined characters from both sides of a string.

The syntax is:

ltrim(string,charlist)

The example is as follows:

<?php
$str = "Hello World!";
echo $str . "<br>";
echo ltrim($str,"Hello");
?>

Output result:

How to remove the symbol on the left side of a character in php

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to remove the symbol on the left side of a character in php. 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