PHP string Processing

Source: Internet
Author: User

PHP string Processing

PHP's string handling capabilities are very powerful, including:

String output

Echo (): Output one or more strings

Print (): Output a string

printf (): Output formatted string

String removal

Trim (): Removes special symbols such as String end and end blanks, or sequences of specified characters

LTrim (): Remove special symbols such as the first whitespace of the string or specify a sequence of characters

RTrim (): Remove special symbols such as string trailing blanks or specify character sequences

Chop (): With RTrim ()

String connection

Implode (): Use characters to combine the contents of an array into a single string

Join (): Same as implode ()

String segmentation

Explode (): Splitting another string with one string

Str_split (): Splitting a string into an array

String fetching

SUBSTR (): Get a portion of it from a string

Strstr (): Finds the position of the first occurrence of a string in another string and returns all characters from that position to the end of the string

SUBCHR (): With Strstr ()

STRRCHR (): Finds the last occurrence of a string in another string and returns all characters from that position to the end of the string

String substitution

Substr_replace (): Replace part of a string with another string

Str_replace (): Replaces other characters in a string with one string

String calculation

Strlen (): Gets the length of the string

Strpos (): Position the first occurrence of a string

Strrpos (): Position the last occurrence of the string

String XHTML formatted display

NL2BR (): Converts line break N to XHTML line break <br/>

Htmlspecialchars (): Convert some special characters to HTML entities

Htmlspecialchars_decode (): Convert some HTML entities to special characters, htmlspecialchars () inverse function

String Storage (escaped)

Addslashes (): Adds an escape character to a special character.

Stripslashes (): Inverse function of addslashes ().

Tip: If you need more complex string handling, you can use regular expressions, see PHP Regular expressions.


PHP string Processing

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.