Home  >  Article  >  Backend Development  >  Summary of usage of PHP Chinese processing tool functions_PHP tutorial

Summary of usage of PHP Chinese processing tool functions_PHP tutorial

WBOY
WBOYOriginal
2016-07-15 13:30:14890browse

in --- PHP Chinese processing tool function space ---

string GBspace(string) ------- -- Add spaces between each Chinese character
string GBunspace(string) ------- Clear spaces between each Chinese character
string clear_space(string) ------- Use To remove extra spaces

--- PHP Chinese processing tool function conversion---

string GBcase(string,offset) --- Convert the string to Convert Chinese and English characters to uppercase and lowercase
offset: "upper" - Convert all strings to uppercase (strtoupper)
"lower" - Convert all strings to lowercase (strtolower)
"ucwords" - Convert characters Change the first letter of each word in the string to uppercase (ucwords)
"ucfirst" - Change the first letter of the string to uppercase (ucfirst)
string GBrev(string) ---------- - Reverse the string

--- PHP Chinese processing tool function 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 all words in the string Whether there is a GB word, it will return true,
otherwise it will return false
int GB_non(string) ------------- Check that all the words in the string are not GB words, yes Will return true,
Otherwise, it will return false
int GBlen(string) -------------- Return the length of the string (Chinese characters only count one letter)

--- PHP Chinese processing tool function search, replacement, extraction---

int/array GBpos(haystack,needle,[offset]) ---- Search string (strpos)
offset: Leave blank - find the first occurrence position
int - search the first occurrence position from this position
"r" - find the last occurrence position (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 characters total 2 letters.

--- Precautions when using PHP Chinese processing tool functions---

If you use the string returned by Form, please pass the string first stripslashes() processing, removing excess.

Usage: Add:
include ("GB.inc");
to the original PHP code to use the above PHP Chinese processing tool function.


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/446314.htmlTechArticleIn --- PHP Chinese processing tool function space --- string GBspace(string) ----- ---- Add space string GBunspace(string) between each Chinese character ------- Clear the space between each Chinese character...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn