Home >Backend Development >PHP Tutorial >ltrim() function in PHP
#ltrim() function is used to remove spaces or other characters from the beginning of a string.
ltrim(str, charlist)
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
<?php $s = " Welcome!"; echo "Without ltrim = " . $s; echo "<br>"; echo "With ltrim = " . ltrim($s); ?>Output
Without ltrim = Welcome! With ltrim = Welcome!
<?php $string = " website"; echo "Welcome to the ".ltrim($string); ?>Output
Welcome to the website
The above is the detailed content of ltrim() function in PHP. For more information, please follow other related articles on the PHP Chinese website!