Phptrim () function example, trim example tutorial _ PHP

Source: Internet
Author: User
Description of phptrim () function instances and trim instances. The phptrim () function example explains how to remove white spaces or other pre-defined characters on both sides of a string from the phptrim () function. This article introduces phptrim () to coders () php trim () function example for function users and trim example

The php trim () function removes white spaces or other pre-defined characters on both sides of the string. This article introduces the usage and examples of the php trim () function to coders, for more information, see.

Definition and usage

The trim () function removes spaces or other predefined characters on both sides of a string.

Related functions:
  • Ltrim ()-removes white spaces or other predefined characters from the left of the string.
  • Rtrim ()-removes spaces or other predefined characters from the right of the string

Syntax
trim(string,charlist)

Parameters Description
String Required. Specifies the string to be checked.
Charlist

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

  • "\ 0"-NULL
  • "\ T"-tab
  • "\ N"-line feed
  • "\ X0B"-vertical tab
  • "\ R"-Press enter
  • ""-Space

Technical details
Return value: Returns the modified string.
PHP version: 4 +
Update Log: In PHP 4.1CharlistParameters.

Instance

Remove spaces on both sides of the string:

 "; Echo" use trim: ". trim ($ str);?>

Online operation

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

Do not use trim: Hello World!
Use trim: Hello World!

The browser output of the above code is as follows:

Do not use trim: Hello World! Use trim: Hello World!

Address: http://www.manongjc.com/article/827.html

Related reading:

The php trim () function removes spaces or other predefined characters on both sides of the string.

The php rtrim () function removes the white space or other predefined characters on the right of the string.

The php trim () function removes spaces or other predefined characters on both sides of the string.

Http://www.bkjia.com/PHPjc/1126525.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1126525.htmlTechArticlephp trim () function example, trim example explains php trim () function removes white spaces or other pre-defined characters on both sides of the string, this article introduces the php trim () function user...

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.