String Trim (String $str [, String $charlist = "\t\n\r\0\x0b"])
This function returns the result of the string str after removing the trailing whitespace characters. If you do not specify a second parameter, trim () will remove these characters:
1. "" (ASCII (0x20)), ordinary whitespace.
2. "\ T" (ASCII 9 (0x09)), tab.
3. "\ n" (ASCII (0x0A)), line break.
4. "\ R" (ASCII (0x0D)), carriage return.
5. "\" (ASCII 0 (0x00)), null byte character.
6. "\x0b" (ASCII One (0x0B)), Vertical tab.
<?php $text = "\t\tthese is a few words:) ... "; $binary = "\x09example string\x0a"; $hello = "Hello World"; $STR = "##\t uses function trim to remove specific characters at both ends of a string"; $new _text = Trim ($text); $new _binary = Trim ($binary); $new _hello = Trim ($hello); $new _str = Trim ($str, "#"); echo $new _text; These is a few words:) ... echo $new _binary; Example string echo $hello; Hello World echo $new _str; Use function trim to remove specific characters at both ends of a string?>
The above function function, also applies to LTrim (), RTrim (), these 2 functions
1, LTrim (); remove whitespace characters (or other characters) at the beginning of a string
2, RTrim (); remove whitespace characters (or other characters) at the end of a string