Common PHP string disposal functions-php Tutorial

Source: Internet
Author: User
Tags convert text to html strtok
Common PHP string processing functions common functions for PHP string operations common functions ** determine string length * intstrlen (stringstr) * compare two strings * 1. the strcmp function performs binary security comparison on the two strings, and Case Sensitive * intstrcmp (stringstr1, stringstr2) * 2. compares two strings in case insensitive * common intstrcas PHP string processing functions

PHP string operations common functions

/*

* Determine the string length

* Int strlen (string str)

* Compare two strings

* 1. the strcmp function performs binary security comparison on two strings and is case sensitive.

* Int strcmp (string str1, string str2)

* 2. compare two strings in case-insensitive mode

* Int strcasecmp (string str1, string str2)

* 3. obtain the same part of the Two Strings.

* Int strspn (string str1, string str2)

* 4. find different parts of two strings

* Int strcspn (string str1, string str2)

* Process string case sensitivity

* 1. convert all strings to lowercase letters.

* String strtolower (string str)

* 2. convert all strings into uppercase letters.

* String strtoupper (string str)

* 3. capital the first character of the string

* String ucfirst (string str)

* 4. convert each word in the string into uppercase letters.

* String ucword (string str)

* String and HTML conversion

* 1. convert a linefeed to an HTML termination mark.

* String bl2br (string str)

* 2. Convert Special characters into wieldHTML equivalent form

* String htmlentities (string str [, int quote_style [, int charset])

* 3. use special HTML characters for other purposes

* String htmlspecialchars (string str [, int quote_style [, string charset])

* 4. convert text to HTML equivalent form

* Array get_html_translaction_table (int table [, int quote_style])

* 5. create a custom conversion list

* String strtr (string str, array replacements)

* 6. Convert HTML to plain text

* String strip_tags (string str [, string allowable_tags])

* Replacement functions of regular expression functions

* 1. the strtok function parses strings based on the predefined string list.

* String strtok (string str, string tonens)

* 2. analyze strings based on predefined delimiters

* Array explode (string separator, string str [, int limit])

* 3. convert an array to a string.

* String implode (string delimiter, array)

* 4. parse complex strings

* Int strpos (string str, string substr [, int offset])

* 5. find the last occurrence of the string

* Int strrpos (string str, char substr [, offset])

* 6. replace all instances of strings with another string

* Mixed str_replace (string occurrence, mixed replacement, mixed str [, int count])

* 7. obtain a part of the string strstr and return the rest of the pre-defined string that begins to appear for the first time.

* String strstr (string str, string occurrence)

* 8. return part of the string based on the predefined offset.

* String substr (string str, int start [, ing length])

* 9. determine the occurrence frequency of the string.

* Int substr_count (string str, string substring)

* 10. replace a part of a string with another string.

* String substr_replace (string str, string replacement, int start [, int length])

* Filling and removing strings

* 1. crop characters starting from strings

* String ltrim (string str [, string charliset])

* 2. crop characters from the end of a string

* String rtrim (string str [, string charliset])

* 3. crop characters from both ends of the string

* String trim (string str [, string charliset])

* 4. fill in strings

* String str_pad (string str, int length [, string pad_string [, int pad_type])

* Character and word count

* 1. string character count

* Mixed count_chars (string str [, mode])

* 2. total number of words in a string

* Mixed str_word_count (string str [, int format])

*/

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.