Home > Article > Backend Development > photoshop cs5 official Chinese official original download php Chinese processing function collection
--- Space ---
string GBspace(string) --------- Add a space between each Chinese character
string GBunspace(string) ------- Between each Chinese character Space clearing
string clear_space(string) ------- Used to clear excess spaces
--- Conversion ---
string GBcase(string,offset) --- Convert the Chinese and English characters in the string to size Write
offset: "upper" - Convert the string to all uppercase (strtoupper)
"lower" - Convert the string to all lowercase (strtolower)
"ucwords" - Convert 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 the string
--- Text check ---
int GB_check (string) ----------- Check whether there is GB word in the string, if so, it will return true,
Otherwise, it will return false
int GB_all(string) ----------- -- Check if all the words in the string have the word GB, it will return true,
Otherwise, it will return false
int GB_non(string) ------------- Check if all the words in the string are not GB word, it will return true,
Otherwise, it will return false
int GBlen(string) -------------- Return the length of the string (Chinese characters only count one letter)
--- Search , replace, extract ---
int/array GBpos(haystack,needle,[offset]) ---- Find string (strpos)
offset: leave blank - find the first occurrence position
int - from this position Search for the first occurrence
"r" - Find the last occurrence (strrpos)
"a" - Store all found words as an array (return array)
string GB_replace(needle,str,haystack) - - Find and replace strings (str_replace)
string GB_replace_i(needle,str_f,str_b,haystack) -- Find and replace strings without checking case
needle - Find letters
str - Replace letters ( str_f - before the letter, str_b After the letter)
haystack - String
string GBsubstr(string,start,[length]) -- Extract a string from start to end or length
length from string.
Chinese characters only count one letter, and positive and negative numbers can be used.
string GBstrnear(string,length) -- Extract the string closest to length from string.
length Chinese Chinese characters are 2 letters long.
--- Note ---
Before using the string returned by Form, please process the string with stripslashes() to remove excess.
Usage: Add:
include ("GB.inc");
to the original PHP code to use the above tool functions.
*/
Copy PHP content to 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?
?>
The above introduces the photoshop cs5 official Chinese version download PHP Chinese processing function collection, including photoshop cs5 official Chinese version download content, I hope it will be helpful to friends who are interested in PHP tutorials.