Summary of common methods for removing string hollow characters in php. Summary of common methods for removing string hollow characters in php this article mainly introduces common methods for removing string hollow characters in php () and common methods for removing string hollow characters in ch php
This article mainly introduces common methods for removing string hollow characters in php. examples of how to use functions such as trim (), ltrim (), rtrim (), and chop () in php are analyzed, it is very practical. For more information, see
This example summarizes the common methods for removing string hollow characters in php. Share it with you for your reference. The specific analysis is as follows:
Php contains four functions that can remove string spaces:
Trim ()-removes null characters at both ends of a string
Ltrim ()-removes null characters from the front-end of the string
Rtrim ()-removes null characters at the end of the string
Chop ()-Same as rtrim ().
The code is as follows:
?
| 1 2 3 4 5 6 7 8 9 |
$ Text = "\ t jb51.net! \ T "; $ LeftTrimmed = ltrim ($ text ); $ RightTrimmed = rtrim ($ text ); $ BothTrimmed = trim ($ text ); Print ("leftTrimmed = ($ leftTrimmed) \ n "); Print ("rightTrimmed = ($ rightTrimmed) \ n "); Print ("bothTrimmed = ($ bothTrimmed) \ n "); ?> |
Output result:
?
| 1 2 3 |
LeftTrimmed = (jb51.net! ) RightTrimmed = (jb51.net !) BothTrimmed = (jb51.net !) |
I hope this article will help you with php programming.
This article mainly introduces the common methods for removing string hollow characters in php. The example analyzes trim (), ltrim (), rtrim (), and ch...