Php Chinese processing function set. --- Space --- stringGBspace (string) --------- add a space between each text in stringGBunspace (string) ------- clear stringclear_space (string) ----- --- space ---
String GBspace (string) --------- add a space between each text
String GBunspace (string) ------- clear spaces between each text
String clear_space (string) ------- used to clear unnecessary spaces
--- Conversion ---
String GBcase (string, offset) --- converts Chinese and English characters in the string into uppercase and lowercase letters.
Offset: "upper"-converts all strings to uppercase (strtoupper)
"Lower"-converts all strings to lowercase (strtolower)
"Ucwords"-change the first letter of each character in the string to uppercase (ucwords)
"Ucfirst"-change the first letter of the string to uppercase (ucfirst)
String GBrev (string) ----------- reverse string
--- Text check ---
Int GB_check (string) ----------- check whether the string contains GB characters. If yes, true is returned,
Otherwise, false is returned.
Int GB_all (string) ------------- check whether all characters in the string contain GB characters. true is returned,
Otherwise, false is returned.
Int GB_non (string) ------------- check whether all characters in the string are not GB characters. true is returned,
Otherwise, false is returned.
Int GBlen (string) -------------- returns the string length (only one letter in Chinese)
--- Search, replace, and extract ---
Int/array GBpos (haystack, needle, [offset]) ---- query string (strpos)
Offset: leave it blank-search for the first position
Int-search for the first location from this location
"R"-find the last position (strrpos)
"A"-save all searched words as an array (return array)
String GB_replace (needle, str, haystack) -- Search for and replace a string (str_replace)
String GB_replace_ I (needle, str_f, str_ B, haystack) -- do not check case sensitivity to search for and replace strings
Needle-search for letters
Str-replace the letter (str_f-before and after the letter str_ B)
Haystack-string
String GBsubstr (string, start, [length]) -- extract from string the length from start to end or
Length string.
Only one letter in the text, positive or negative.
String GBstrnear (string, length) -- extract the string closest to length from string.
Length is a string of 2 letters.
--- Note ---
If you want to use the string returned by Form, perform stripslashes () processing on the string first to remove unnecessary \.
Usage: add the following in the original PHP code:
Include ("GB. inc ");
You can use the above tool functions.
*/
Copy the PHP content to the clipboard.
Function GBlen ($ string ){
$ L = strlen ($ string );
$ Ptr = 0;
$ A = 0;
While ($ a <$ l ){
$ Ch = substr ($ string, $ a, 1 );
$ Ch2 = substr ($ string, $ a + 1, 1 );
If (ord ($ ch)> = HexDec ("0x81") & ord ($ ch2)> = HexDec ("0x40 ")){
$ Ptr ++;
$ A + = 2;
} Else {
$ Ptr ++;
$ A ++;
} // END IF
} // End whi?
?>
Http://www.bkjia.com/PHPjc/319462.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/319462.htmlTechArticle --- space --- string GBspace (string) --------- add a space between each text string GBunspace (string) ------- clear the space between each text string clear_space (string )-----...