Common methods for removing string hollow characters in php _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.