Detailed Introduction PHP chinese processing function Large Aggregation _php tutorial

Source: Internet
Author: User

---the space of the PHP Chinese processing function---

String Gbspace (String)---------spaces between each text
String Gbunspace (String)-------white space between each text
String Clear_space (String)-------used to clear extra spaces

---The conversion---of PHP chinese processing function

String gbcase (String,offset)---Converts the Chinese and English characters inside a string into uppercase and lowercase
Offset: "Upper"-string full capitalization (Strtoupper)
"Lower"-full string converted to lowercase (strtolower)
"Ucwords"-capitalize the first letter of each word of the string (ucwords)
"Ucfirst"-capitalizes the first letter of the string (Ucfirst)
String Gbrev (String)-----------upside down strings

---the text check of PHP Chinese processing function---

int Gb_check (string)-----------Check if there is a GB word inside the string, there will be a return of true,
Otherwise it will return false
int Gb_all (string)-------------check if all the words in the string have a GB word, it will return true.
Otherwise it will return false
int Gb_non (string)-------------check that all the words inside the string are not gigabytes, and that it returns true.
Otherwise it will return false
int Gblen (String)--------------returns the length of the string (only one letter in Chinese text)

---The search, substitution, extraction---of php chinese processing function

Int/array Gbpos (Haystack,needle,[offset])----Find string (Strpos)
Offset: Empty-finds the first occurrence of the position
INT-the first position to be searched by the location
"R"-Find the last occurrence (Strrpos)
"A"-stores all found words in an array (returns an array)

String Gb_replace (Needle,str,haystack)--Find and replace string (str_replace)
String Gb_replace_i (Needle,str_f,str_b,haystack)--Do not check case lookup vs. replace string
Needle-Find letters
STR-Substituted letter (Str_f-Before the letter, str_b the letter)
Haystack-string

String Gbsubstr (String,start,[length])-Extracts from a string from start to end or length
The length of the string.
The Chinese text only counts one letter and can use positive negative numbers.
String Gbstrnear (string,length)-extracts the string closest to length from a string.
Length in Chinese characters 2 letters.

---PHP chinese processing function Considerations---

If you use the string returned by the Form, precede the string with stripslashes (), removing the superfluous.

To use: In the original PHP code, add:
Include ("Gb.inc");
You can use the above tool functions.

 
 
  1. */
  2. < ? PHP
  3. function Gblen ($string) {
  4. $ L = strlen ($string);
  5. $ ptr = 0 ;
  6. $ a = 0 ;
  7. While ($a < $l) {
  8. $ CH = substr ($string, $a, 1);
  9. $ CH2 = substr ($string, $a +1,1);
  10. if (ord ($ch) >= Hexdec ("0x81")
    && Ord ($ch 2) >= Hexdec ("0x40")) {
  11. $ptr + +;
  12. $a + = 2;
  13. } else {
  14. $ptr + +;
  15. $a + +;
  16. }//END IF
  17. }//END WHI?
  18. ?>


http://www.bkjia.com/PHPjc/445919.html www.bkjia.com true http://www.bkjia.com/PHPjc/445919.html techarticle ---The white space of the PHP Chinese processing function---string gbspace (String)---------the space between each text string Gbunspace (string)-------the space between each text in the string ...

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