Remove characters on the left side of a string ("He" in "Hello" and "d!" in "World"):
<?php$str = "Hello World!";echo $str . "<br>";echo trim($str,"Hed!");?>The trim() function removes whitespace or other predefined characters from either side of a string.
Related functions:
ltrim() - Removes whitespace characters or other predefined characters from the left side of a string.
rtrim() - Removes whitespace characters or other predefined characters on the right side of a string.
trim( string,charlist )
parameter | describe |
---|---|
string | Required. Specifies the string to check. |
charlist | Optional. Specifies which characters are removed from a string. If this parameter is omitted, all the following characters are removed: " |