Introduces a set of Chinese processing tool functions _php
Source: Internet
Author: User
Keywords functions tools Handling Chinese intro NE
/* Chinese processing tool functions
---space---
String Gbspace (String)---------spaces between each text
String Gbunspace (String)-------white space between each text
String Clear_space (String)-------used to clear extra spaces
---conversion---
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
---text check---
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)
---find, replace, extract---
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.
---note---
If you use the string returned by the Form, precede the string with stripslashes (), removing the redundant \.
To use: In the original PHP code, add:
Include ("Gb.inc");
You can use the above tool functions.
*/
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.