PHP Go space trim Invalid with Str_replace implementation _php Tutorial

Source: Internet
Author: User
Tags rtrim
PHP go space has the correlation function trime, he can remove two spaces or directly use LTrim and RTrim function results with trim, if you want to delete all the spaces only use str_replace replaced.

Usually over the space, is generally used trim, found today, the middle of the space to go. Pour, check the instructions to know, trim can only go to both ends, such as $abc = a b c; , with trim can only remove the space behind a front C, but what about the space around B? Str_replace out, that's it.

The code is as follows Copy Code

Str_replace (",", $ABC).

Need to go to the space of the students carefully, PHP to space, trim not, str_replace line, but trim can remove the head space as follows

Cases

The code is as follows Copy Code

Trim removes a string at both ends of a space,
RTrim is to remove a string to the right of the space,
LTrim is to remove the left space of a string.

Echo Trim ("Space www.bKjia.c0m"). "
";
echo RTrim ("Space"). "
";
Echo LTrim ("Space"). "
";
?>

The effect is the same as the str_replace.

http://www.bkjia.com/PHPjc/633056.html www.bkjia.com true http://www.bkjia.com/PHPjc/633056.html techarticle PHP Go space has the correlation function trime, he can remove two spaces or directly use LTrim and RTrim function results with trim, if you want to delete all the spaces only use str_replace replaced. ...

  • 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.