Welcome to the Linux community forum and interact with 2 million technical staff. Use php to get the first letter of Chinese Character and pinyin, for example, get the first letter of Z from the self-learning network. The Code is as follows :? Phpfunctiongetfirstchar ($ s0) {$ firstchar_ordord (strtoupper ($ s0 {0}); if ($ firstchar_ord65and $ firstchar_ord91
Welcome to the Linux community forum and interact with 2 million technical staff> go to php to get the first letter of Chinese Character and pinyin, for example, get the first letter of Z from the self-learning network. The Code is as follows :? Php function getfirstchar ($ s0) {$ firstchar_ord = ord (strtoupper ($ s0 {0}); if ($ firstchar_ord = 65 and $ firstchar_ord = 91
Welcome to the Linux community forum and interact with 2 million technicians>
Use php to get the first letter of Chinese Character and pinyin, for example, get the first letter of Z through self-learning.
The Code is as follows:
Function getfirstchar ($ s0 ){
$ Firstchar_ord = ord (strtoupper ($ s0 {0 }));
If ($ firstchar_ord> = 65 and $ firstchar_ord <= 91) or ($ firstchar_ord> = 48 and $ firstchar_ord <= 57) return $ s0 {0 };
// $ S = iconv ("UTF-8", "gb2312", $ s0 );
$ S = $ s0;
$ Asc = ord ($ s {0}) * 256 + ord ($ s {1})-65536;
If ($ asc >=- 20319 and $ asc <=-20284) return "";
If ($ asc >=- 20283 and $ asc <=-19776) return "B ";
If ($ asc >=- 19775 and $ asc <=-19219) return "C ";
If ($ asc >=- 19218 and $ asc <=-18711) return "D ";
If ($ asc >=- 18710 and $ asc <=-18527) return "E ";
If ($ asc >=- 18526 and $ asc <=-18240) return "F ";
If ($ asc >=- 18239 and $ asc <=-17923) return "G ";
If ($ asc >=- 17922 and $ asc <=-17418) return "H ";
If ($ asc >=- 17417 and $ asc <=-16475) return "J ";
If ($ asc >=- 16474 and $ asc <=-16213) return "K ";
If ($ asc >=- 16212 and $ asc <=-15641) return "L ";
If ($ asc >=- 15640 and $ asc <=-15166) return "M ";
If ($ asc >=- 15165 and $ asc <=-14923) return "N ";
If ($ asc >=- 14922 and $ asc <=-14915) return "O ";
If ($ asc >=- 14914 and $ asc <=- 14631) return "P ";
If ($ asc >=- 14630 and $ asc <=-14150) return "Q ";
If ($ asc >=- 14149 and $ asc <=-14091) return "R ";
If ($ asc >=- 14090 and $ asc <=-13319) return "S ";
If ($ asc >=- 13318 and $ asc <=-12839) return "T ";
If ($ asc >=- 12838 and $ asc <=-12557) return "W ";
If ($ asc >=- 12556 and $ asc <=-11848) return "X ";
If ($ asc >=- 11847 and $ asc <=-11056) return "Y ";
If ($ asc >=- 11055 and $ asc <=- 10247) return "Z ";
Return null;
}
Var_dump (getfirstchar (" "));
?>