This article mainly introduces the common methods of removing hollow characters in strings in PHP, and analyzes trim() in PHP with examples. The usage skills of functions such as , ltrim(), rtrim() and chop() are of great practical value. Friends in need can refer to it
The example in this article summarizes the common methods of removing null characters in strings in PHP. Share it with everyone for your reference. The specific analysis is as follows:
php contains four functions that can remove spaces from strings:
trim() – removes null characters from both ends of a string
ltrim() – removes null characters at the front of a string
rtrim() – removes null characters at the end of a string
chop() – same as rtrim().
The code is as follows:
?
3 4
5
6
9 |
|
?>
1 2 3 | leftTrimmed = (jb51.net! ) rightTrimmed = ( jb51.net!) bothTrimmed = (jb51.net!) |