PHP some common String functions summary _php Tutorial

Source: Internet
Author: User
Tags chop crypt echo display sprintf strtok
1, addcslashes string add backslash
Syntax: String addcslashes (String str,string charlist);

2, addslashes string add backslash
Syntax: string addslashes (String str);
Preceded by a specific character with a backslash: ', ', \, NULL

3, Bin2Hex the binary into 16
Syntax: string bin2hex (String str);

4, Chop remove continuous blank, with RTrim ()
Syntax: String chop (String str);

5. CHR CHR returns characters based on ASCII values
Syntax: string chr (int ascii);

6. Chunk_split the string into small segments
Syntax: String chunk_split (String string,int [chunklen],string [end]);

7. convert_cyr_string string Inner code conversion
Syntax: String convert_cyr_string (String str,string from,string to);

8, Count_chars Returns the information of the string
Syntax: Mixed Count_chars (string string,[mode]);

9. Crypt return string encrypted with DES encoding
Syntax: String crypt (String str,string [salt]);

10. Echo Display Content
Syntax: Echo (String arg1,string [argn] ...);

11. Explode cutting string
Syntax: Array explode (string separator,string string);

12. Flush clears the output buffer
Syntax: OID flush (void);

13, get_html_translation_table return function Htmlspecialchars () and htmlentites () Character conversion table
Syntax: string get_html_translation_table (int table);

14. Get_meta_tags extract all meta tag data from the file
Syntax: Array get_meta_tags (String filename,int [Use_include_path])

15, htmlentities all the characters to the people HTML string
Syntax: String htmlentities (String string);

16, htmlspecialchars the special characters into HTML format
Syntax: String htmlspecialchars (String string);

17. Implode the array into a string
Syntax: String implode (string glue,array pieces);

18. Join converts an array into a string
Syntax: String join (string glue,array,pieces);

19, LTrim remove continuous blank
Syntax: String LTrim (String str);

20. MD5 using MD5 for string processing
Syntax: string MD5 (string str);

21. Metaphone returns the phonetic value of a string
Syntax: string metaphome (String str);

22, NL2BR will change characters into

Syntax: String nl2br (String string);

23. Ord Gets the ASCII code value of the character
Syntax: int ord (string string);

24, Parse_str (string str);
Syntax: Vid parse_str (String str)

25. Print output string
Syntax: print (string arg);

26. printf Output formatted string
Syntax: int printf (string format,mixed [args] ...);

27. Quoted_printable_decode the QP encoded string into an octal string

28, Quotemeta special character match either add backslash

29. Rawurldecode decoding a string encoded in URL mode
Syntax: string rawurldecode (String str);

30. Rawurlencode encoding string into URL-specific format

31, setlocale set Local information
Syntax: String setlocale (String category,string locale);

32. Similar_text Calculation of string similarity
Syntax: int similar_text (string first,string second,double [percent]);

33. Soundex returns the phonetic value of a string
Syntax: String soundex (String str);

34. sprintf String Formatting
Syntax: String sprintf (String format,mixed [args] ...);

35. STRCASECMP case-insensitive string comparison of binary methods
Syntax: int strcasecmp (string str1,string st2);

36, STRCHR look for the first occurrence of the character
Syntax: String strchr (String haystack,string needle);

37. strcmp string comparison of case-sensitive binary methods
Syntax: int strcmp (string str1,string str2);

38, strcspn the length of different strings
Syntax: int strcspn (string str1,string st2);

39, strip_tags Remove the HTML and PHP tags
Syntax: String strip_tags (String str,string [allowable_tags]);

40. Stripcslashes Remove Backslash string
Syntax: string stripcslashes (String str);

41. stripslashes Remove Backslash characters
Syntax: string stripslashes (String str);

42. STRISTR returns the contents of a string that appears in another string
Syntax: String stristr (String haystack,string needle);

43, strlen get the length of the string

44. Strpos gets the position where a character in the string first appears
Syntax: int strpos (string haystack,string needle,int [offset]);

45. STRRCHR gets the string at the last occurrence of a character
Syntax: String strrchr (String haystack,string needle);

46. Str_repet repeats a string
Syntax: Str_repeat (string Input,int multiplier);

47. Strrev Inverted string
Syntax: String Strrev (String string);

48. Strrpos search for the last occurrence of a character in a string
Syntax: int strrpos (string Haystack,char needle);

49. STRSPN calculates the number of occurrences of a string in another string
Syntax: int strspn (string str1,string str2);

50. STRSTR returns the contents of a string that appears in another string
Syntax: String strstr (String haystack,string needle);

51. Strtok Cutting String
Syntax: String strtok (String arg1, string arg2);
With the string arg2 as the delimiter, the cut string arg1, arg2 can be placed in multiple separators.

52. Strtolower string Full lowercase
Syntax: string strtolower (String str);

53. Strtoupper String Full capitalization
Syntax: string strtoupper (String str);

54. Str_replace String Substitution
Syntax: Str_replace (string needle,string str,string haystack);
Replace all strings in the String haystack Str is needle. This function can be replaced with ereg_replace ().

55. STRTR String Substitution
Syntax: string strtr (String str, string from, string to);
Character substitution, the string str contains one by one of the from character corresponding to the character in to. If the number of characters from and to is not the same, the extra characters are ignored, and the substitution of this function is a character instead of a word or string substitution.

56, substr take part of the string
Syntax: String substr (string string, int start, int [length]);

57. Substr_replace String Substitution
Syntax: String substr_replace (string string,string replacement, int start, int [length]);
Extracts a string from a string and replaces it with a replacement, with the parameter start and length defined and used in the same way as SUBXSTR.

58, Trim cut off the string end of the space
Syntax: string trim (string str);

59. Ucfirst change the first character of the string to uppercase
Syntax: string ucfirst (String str);

60. Ucwords to capitalize the first letter of each word in a string
Syntax: string ucwords (String str);

http://www.bkjia.com/PHPjc/752589.html www.bkjia.com true http://www.bkjia.com/PHPjc/752589.html techarticle 1, addcslashes string added backslash syntax: string addcslashes (String str,string charlist), 2, addslashes string added backslash syntax: string Addslashes (string str); In the special ...

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