ltrim() function in php
0 1927
ltrim() function of PHP is used to remove some user-defined characters or white space from the left side of a PHP string. It is an inbuilt function of PHP. The return type of this function is a string.
Note:
a) If you want to remove some user-defined text or white space from the right side of any string, use rtrim() PHP function.
b) If you want to remove some user-defined text or white space from both sides of any string, use trim() PHP function.
Syntax:
ltrim($string,$characters);
here,
- $string is a PHP string from which we want to remove either some predefined texts or white space used by this function. It is mandatory.
- $characters are user-defined text which we want to remove from the given string. It is optional.
Example:
<?php $str="Most welcome to coding tag"; $u_str=ltrim($str,"Most"); echo "Old string is : $str <br>"; echo "Modified string is : $u_str"; ?>
Output:
Share:
Comments
Waiting for your comments