PHP trim () function examples, trim examples to explain _php tutorial

Source: Internet
Author: User

PHP trim () Function example explained, trim example explained


The PHP trim () function removes whitespace characters or other predefined characters on either side of the string, and this article introduces the usage and examples of the PHP trim () function to the code farmer, which is of interest to the code farmer.

Definition and usage

The trim () function removes white space characters or other predefined characters on either side of the string.

Related functions:

    • LTrim ()-removes white space characters or other predefined characters to the left of the string
    • RTrim ()-Remove whitespace characters or other predefined characters to the right of the string

Grammar

Trim (string,charlist)

Parameters Description
String Necessary. Specifies the string to check.
Charlist

Optional. Specifies which characters are removed from the string. If omitted, all of the following characters will be removed:

  • "+"-NULL
  • "\ T"-tab
  • "\ n"-line break
  • "\X0B"-Vertical tab
  • "\ r"-Enter
  • ""-Space

Technical details

return value: Returns the modified string
PHP version: 4 +
Update log: In PHP 4.1, the charlist parameter has been added.

Instance

To remove spaces on either side of a string:

 
  "; echo" using Trim: ". Trim ($STR);? >

Run online

The HTML output of the above code is as follows (see source code):

Do not use Trim:  
Using Trim:hello world!

The browser output of the above code is as follows:

Use Trim:hello world! without using Trim:hello world!

Original address: http://www.manongjc.com/article/827.html

Related reading:

The PHP trim () function removes white space characters or other predefined characters on either side of the string

The PHP RTrim () function removes white space characters or other predefined characters to the right of the string

The PHP trim () function removes white space characters or other predefined characters on either side of the string

http://www.bkjia.com/PHPjc/1126525.html www.bkjia.com true http://www.bkjia.com/PHPjc/1126525.html techarticle the PHP trim () Function example explains that the trim instance explains that the PHP trim () function removes whitespace characters or other predefined characters on either side of the string, and this article introduces the user of the PHP trim () function to the code farm ...

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