Create php in the pinyin Library. The pinyin database creates php to obtain the Chinese name from a database and all possible uppercase letters and combinations of pinyin. And then import it to another database with the name;} ret pinyin library creates php
It is mainly used to obtain the Chinese name from a database and all uppercase letters that may be pinyin. Then import the database with the name.
";} Return $ temp;} // permutation and combination function, which can be a combination of all uppercase letters. for example, the uppercase spelling of the Bank of China may be" ZGYH "and" ZGYX "error_reporting (E_ALL &~ E_NOTICE); function get_new_arr () {$ args = func_get_args (); // Get the array of all input parameters $ arr = array (); foreach ($ args as $ k =>$ v) {if ($ args [$ k + 1]) {switch ($ k) {case 0: $ arr [$ k] = arr_pailie ($ v, $ args [$ k + 1]); break; default: $ arr [$ k] = arr_pailie ($ arr [$ k-1], $ args [$ k + 1]); break ;}}$ key = count ($ arr) -1; $ res = implode ('. ', $ arr [$ key]); return $ res;} function arr_pailie ($ arr1, $ arr2) {$ arr = array (); $ k = 0; foreach ($ arr1 as $ k1 => $ v 1) {foreach ($ arr2 as $ k2 => $ v2) {$ arr [$ k] = $ v1 .",". $ v2; $ k ++;} return $ arr;} // database connection, retrieve the name and ID $ dbname = "DB1 "; $ servcon = mysql_connect (MySql database address, user name, account); if (! $ Servcon) {die ("Fail to connect to DataBase! Error :". mysql_error ();} mysql_select_db ($ dbname, $ servcon); $ select = mysql_query ("select Symbol, Name from smallsnapshoot"); // database connection, directly input the stock conversion result to the database stockdb py_convert table $ dbname1 = "DB2"; $ servcon1 = mysql_connect (MySql database address, user name, account); if (! $ Servcon1) {die ("Fail to connect to DataBase! Error :". mysql_error ();} mysql_select_db ($ dbname1, $ servcon1); // cyclically retrieve the name and ID of each row in the source database while ($ row = mysql_fetch_array ($ select )) {// enter Chinese characters one by one for search and save them to the $ arr_list array // $ str = "bank order"; $ str = $ row ["Name"]; $ len = mb_strlen ($ str, "UTF-8"); $ arr_list = array (); for ($ I = 0; $ I <$ len; $ I ++) {$ arr [] = mb_substr ($ str, $ I, 1, "UTF-8"); $ arr_list [$ I] = get_firstchar ($ arr [$ I]);} // echo $ arr_list [3]; // cyclically retrieve the letters in each character array and save them to $ arr_str. // call the permutation and combination function, first, convert each element of the string array into a pair array, because the environment name can be up to three words or four words $ arr1 = array (); $ arr2 = array (); $ arr3 = array (); $ arr1 = str_split ($ arr_list [0]); $ arr2 = str_split ($ arr_list [1]); $ arr3 = str_split ($ arr_list [2]); if (count ($ arr_list) = 4) {$ arr4 = array (); $ arr4 = str_split ($ arr_list [3]); $ result = get_new_arr ($ arr1, $ arr2, $ arr3, $ arr4); // echo count ($ arr_list );} else {$ result = get_new_arr ($ arr1, $ arr2, $ arr3); // echo count ($ arr_list);} // echo $ result; // Convert the combined data into an array and delete the repeated array $ arr_str = array (); $ arr_str = explode ('. ', $ result); // echo $ arr_str [1]; for ($ I = 0; $ I
Because the name of the Chinese character is involved, the editing environment used is the UTF-8. The permutation and combination functions are intended for reference by others. if you think about them for a long time, the effect is poor. The key is that the data logic thinking is unclear, which shows the importance of data thinking.
I am also learning and doing it myself. I am not very skilled in calling php functions. I will strengthen programming exercises in the future. If something is not well written, you are welcome to correct and communicate with each other and make progress together!
Ghost php is mainly used to obtain the Chinese name from a database and obtain all uppercase letters that may be pinyin. Then import the database with the name;} ret...