Full version of String processing functions in PHP

Source: Internet
Author: User
Tags md5 hash
Address: www. phpthinking. comarchives602 development habits common string processing function combing: strtr () Conversion string specific characters. Substr () returns part of the string. Strstr () searches for the first occurrence of a string in another string (case sensitive) str_replace () to replace some characters in the string

Address: http://www.phpthinking.com/archives/602 development habits commonly used string processing function combing: strtr () Conversion string specific characters. Substr () returns part of the string. Strstr () searches for the first occurrence of a string in another string (case sensitive) str_replace () to replace some characters in the string

Address: http://www.phpthinking.com/archives/602

Common string processing functions used for development:
Strtr () is a special character in the conversion string.
Substr () returns part of the string.
Strstr () first appearance of a string in another string (case sensitive)
Str_replace () replaces some characters in the string. (Case Sensitive)
Strcmp () compares two strings. (Case Sensitive)
Strlen () returns the length of the string.
Substr_count () calculates the number of times a substring appears in a string.
Substr_replace () replaces a part of the string with another string.

Implode () combines array elements into a string.
Explode () splits the string into an array using the specified separator

Json_encode () parses the array into a json string
Json_decode () parses the json string into an array element.
String handler function list:

Addcslashes () adds a backslash before the specified character.
Addslashes () adds a backslash before the specified predefined character.
Bin2hex () converts the ASCII character string to a hexadecimal value.
The alias of chop () rtrim.
Chr () returns characters from the specified ASCII value.
Chunk_split () splits the string into a series of smaller parts.
Convert_cyr_string () converts a character from one Cyrillic to another.
Convert_uudecode () decodes uencode.
Convert_uuencode () uses the uuencode algorithm to encode the string.
Count_chars () returns the characters used by the string.
Crc32 () calculates the 32-bit CRC of a string.
Crypt () one-way string encryption (hashing ).
Echo () Output string.
Explode () splits the string into an array.
Fprintf () writes formatted strings to the specified output stream.
Get_html_translation_table () returns the translation table.
Hebrev () switches the flow from right to left to the flow from left to right.
Hebrevc () is the same as above, and converts (\ n)
.
Html_entity_decode () converts HTML objects into characters.
Htmlentities () converts characters to HTML entities.
Htmlspecialchars_decode () converts some predefined HTML entities into characters.
Htmlspecialchars () converts some predefined characters into HTML objects.
Implode () combines array elements into a string.
The alias of join () implode.
Levenshtein () returns the Levenshtein distance between two strings.
Localeconv () returns an array containing local numbers and currency information formats.
Ltrim () removes spaces or other predefined characters from the left side of the string.
Md5 () calculates the MD5 hash of the string.
Md5_file () calculates the MD5 hash of the file.
Metaphone () calculates the metaphone key of the string.
Money_format () format the string as a currency string.
Nl_langinfo () returns the specified local information.
Nl2br () inserts an HTML line break before each new line in the string.
Number_format () uses a kilobytes of data to format numbers.
Ord () returns the ASCII value of the first character of the string.
Parse_str () parses the query string to the variable.
Print () Outputs one or more strings.
Printf () Outputs formatted strings.
Quoted_printable_decode () decodes the quoted-printable string.
Quotemeta () adds a backslash before some predefined characters in the string.
Rtrim () removes white spaces or other predefined characters from the end of the string.
Setlocale () sets region information (region information ).
Sha1 () calculates the SHA-1 hash of the string.
The SHA-1 hash of the calculation file.
Similar_text () calculates the number of matching characters for two strings.
Soundex () calculates the soundex key of the string.
Sprintf () writes formatted strings to a variable.
Sscanf () parses input from a string according to the specified format.
Str_ireplace () replaces some characters in the string. (Case Insensitive)
Str_pad () fills the string with a new length.
Str_repeat () specifies the number of times the string is repeated.
Str_replace () replaces some characters in the string. (Case Sensitive)
Str_rot13 () executes the ROT13 encoding on the string.
Str_shuffle () randomly breaks all characters in the string.
Str_split () splits the string into arrays.
Str_word_count () calculates the number of words in the string.
Strcasecmp () compares two strings. (Case Insensitive)
Strchr () searches for the first occurrence of a string in another string. Alias of strstr ()
Strcmp () compares two strings. (Case Sensitive)
Strcoll () compares two strings (depending on local settings ).
Returns the number of characters searched in the string before any specified character is found.

Stripcslashes () deletes the backslash added by the addcslashes () function.
Stripslashes () deletes the backslash added by the addslashes () function.
Stripos () returns the position of the first occurrence of the string in another string (Case Insensitive)
Stristr () is used to locate the first occurrence of a string in another string (Case Insensitive)
Strlen () returns the length of the string.
Strnatcasecmp () uses a "natural" algorithm to compare two strings (Case Insensitive)
Strnatcmp () uses a "natural" algorithm to compare two strings (case sensitive)
String comparison of the First n characters of strncasecmp () (Case Insensitive ).
String comparison of the First n characters of strncmp () (case sensitive ).
Strpbrk () searches for any of the specified characters in the string.
Strpos () returns the position of the first occurrence of the string in another string (case sensitive)
Strrchr () is used to locate the last occurrence of a string in another string.
Strrev () reverses the string.
Strripos () searches for the last position of the string in another string (Case Insensitive)
Strrpos () is used to locate the last occurrence of a string in another string (case sensitive)
Strspn () returns the number of specific characters contained in the string.
Strstr () first appearance of a string in another string (case sensitive)
Strtok () Splits a string into smaller strings.
Strtolower () converts a string to lowercase.
Strtoupper () converts a string to uppercase.
Strtr () is a special character in the conversion string.
Substr () returns part of the string.
Substr_compare () compares two strings from the specified start length.
Substr_count () calculates the number of times a substring appears in a string.
Substr_replace () replaces one part of the string with another.
Trim () removes spaces and other predefined characters from both ends of the string.
Ucfirst () converts the first character in the string to uppercase.
Ucwords () converts the first character of each word in a string to uppercase.
Vfprintf () writes formatted strings to the specified output stream.
Vprintf () Outputs formatted strings.
Vsprintf () writes the formatted string to the variable.
Wordwrap () is used to fold a string based on the specified length.

For detailed usage, see: http://cn2.php.net/ref.strings.php

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.