--- 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: In the original PHPCodeAdd:
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?
?>