i have a string like below
$string = ' florida'
how can i remove white space from beginning ONLY to form it like below.
$result_string = 'florida'
i am sorry if it is too easy question.
String result = str. trim(); The trim() method will remove both leading and trailing whitespace from a string and return the result.
The trim() function removes whitespace and other predefined characters from both sides of a string. Related functions: ltrim() - Removes whitespace or other predefined characters from the left side of a string. rtrim() - Removes whitespace or other predefined characters from the right side of a string.
Method 1: Using ltrim() Method: The ltrim() method is used to strip whitespace only from the beginning of a string.
The trim() function in PHP removes whitespace or any other predefined character from both the left and right sides of a string. ltrim() and rtrim() are used to remove these whitespaces or other characters from the left and right sides of the string.
$string = ' florida'
$result_string = ltrim($string);
echo $result_string;// it will remove white spces from beganing
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With