LTrim (), RTrim () and trim () Delete word spaces instances in PHP, ltrimrtrim_php tutorial

Source: Internet
Author: User
Tags rtrim

PHP LTrim (), RTrim () and trim () Delete Word spaces instances, Ltrimrtrim


This example describes how to delete a word spaces in PHP ltrim (), RTrim (), and trim (). Share to everyone for your reference. The specific analysis is as follows:

The trim function in PHP does not have to be the same as in ASP, can automatically delete all spaces, PHP professional provides the RTrim () trim () function, interested in this friend can refer to.

The PHP instance code is as follows:
Copy the Code code as follows: <?php
$STR = "Remove space before and after";
echo "The original string in square brackets: [". $str. "]
";
echo "Raw string length:". strlen ($STR). "
";
$str 1=ltrim ($STR);
echo "Executes the length after LTrim ():". strlen ($str 1). "
";
$str 2=rtrim ($STR);
echo "Executes the length after RTrim ():". strlen ($str 2). "
";
$str 3=trim ($STR);
echo "The length after the trim () is performed:". strlen ($str 3). "
";
echo "Remove the string after the trailing space: [". $str 3. "]";
?>

I hope this article is helpful to everyone's PHP programming.

http://www.bkjia.com/PHPjc/917039.html www.bkjia.com true http://www.bkjia.com/PHPjc/917039.html techarticle php LTrim (), RTrim () and trim () Delete Word spaces instances, Ltrimrtrim This example describes the LTrim (), RTrim () and trim () methods in PHP to delete the word spaces lattice. Share to everyone for your reference ...

  • Related Article

    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.