php gets the first letter of Chinese characters

WBOY
Release: 2016-07-25 08:42:04
Original
1551 people have browsed it

php get initial letter

[PHP] code

  1. $d = array(
  2. array("a",-20319),
  3. array("ai",-20317),
  4. array("an",-20304),
  5. array("ang",-20295),
  6. array("ao",-20292),
  7. array("ba",-20283),
  8. array("bai",-20265),
  9. array("ban",-20257),
  10. array("bang",-20242),
  11. array("bao",-20230),
  12. array("bei",-20051),
  13. array("ben",-20036),
  14. array("beng",-20032),
  15. array("bi",-20026),
  16. array("bian",-20002),
  17. array("biao",-19990),
  18. array("bie",-19986),
  19. array("bin",-19982),
  20. array("bing",-19976),
  21. array("bo",-19805),
  22. array("bu",-19784),
  23. array("ca",-19775),
  24. array("cai",-19774),
  25. array("can",-19763),
  26. array("cang",-19756),
  27. array("cao",-19751),
  28. array("ce",-19746),
  29. array("ceng",-19741),
  30. array("cha",-19739),
  31. array("chai",-19728),
  32. array("chan",-19725),
  33. array("chang",-19715),
  34. array("chao",-19540),
  35. array("che",-19531),
  36. array("chen",-19525),
  37. array("cheng",-19515),
  38. array("chi",-19500),
  39. array("chong",-19484),
  40. array("chou",-19479),
  41. array("chu",-19467),
  42. array("chuai",-19289),
  43. array("chuan",-19288),
  44. array("chuang",-19281),
  45. array("chui",-19275),
  46. array("chun",-19270),
  47. array("chuo",-19263),
  48. array("ci",-19261),
  49. array("cong",-19249),
  50. array("cou",-19243),
  51. array("cu",-19242),
  52. array("cuan",-19238),
  53. array("cui",-19235),
  54. array("cun",-19227),
  55. array("cuo",-19224),
  56. array("da",-19218),
  57. array("dai",-19212),
  58. array("dan",-19038),
  59. array("dang",-19023),
  60. array("dao",-19018),
  61. array("de",-19006),
  62. array("deng",-19003),
  63. array("di",-18996),
  64. array("dian",-18977),
  65. array("diao",-18961),
  66. array("die",-18952),
  67. array("ding",-18783),
  68. array("diu",-18774),
  69. array("dong",-18773),
  70. array("dou",-18763),
  71. array("du",-18756),
  72. array("duan",-18741),
  73. array("dui",-18735),
  74. array("dun",-18731),
  75. array("duo",-18722),
  76. array("e",-18710),
  77. array("en",-18697),
  78. array("er",-18696),
  79. array("fa",-18526),
  80. array("fan",-18518),
  81. array("fang",-18501),
  82. array("fei",-18490),
  83. array("fen",-18478),
  84. array("feng",-18463),
  85. array("fo",-18448),
  86. array("fou",-18447),
  87. array("fu",-18446),
  88. array("ga",-18239),
  89. array("gai",-18237),
  90. array("gan",-18231),
  91. array("gang",-18220),
  92. array("gao",-18211),
  93. array("ge",-18201),
  94. array("gei",-18184),
  95. array("gen",-18183),
  96. array("geng",-18181),
  97. array("gong",-18012),
  98. array("gou",-17997),
  99. array("gu",-17988),
  100. array("gua",-17970),
  101. array("guai",-17964),
  102. array("guan",-17961),
  103. array("guang",-17950),
  104. array("gui",-17947),
  105. array("gun",-17931),
  106. array("guo",-17928),
  107. array("ha",-17922),
  108. array("hai",-17759),
  109. array("han",-17752),
  110. array("hang",-17733),
  111. array("hao",-17730),
  112. array("he",-17721),
  113. array("hei",-17703),
  114. array("hen",-17701),
  115. array("heng",-17697),
  116. array("hong",-17692),
  117. array("hou",-17683),
  118. array("hu",-17676),
  119. array("hua",-17496),
  120. array("huai",-17487),
  121. array("huan",-17482),
  122. array("huang",-17468),
  123. array("hui",-17454),
  124. array("hun",-17433),
  125. array("huo", -17427),
  126. array("ji",-17417),
  127. array("jia",-17202),
  128. array("jian",-17185),
  129. array("jiang",-16983),
  130. array ("jiao",-16970),
  131. array("jie",-16942),
  132. array("jin",-16915),
  133. array("jing",-16733),
  134. array("jiong",- 16708),
  135. array("jiu",-16706),
  136. array("ju",-16689),
  137. array("juan",-16664),
  138. array("jue",-16657),
  139. array( "jun",-16647),
  140. array("you",-16474),
  141. array("kai",-16470),
  142. array("kan",-16465),
  143. array("you",-16459 ). kong",-16427),
  144. array("you",-16423),
  145. array("my",-16419),
  146. array("he",-16412),
  147. array("my",-16407) ,
  148. array("say",-16403),
  149. array("say",-16401),
  150. array("kui",-16393),
  151. array("if",-16220),
  152. array("kuo ",-16216),
  153. array("la",-16212),
  154. array("lai",-16205),
  155. array("lan",-16202),
  156. array("lang",-16187),
  157. array("lao",-16180),
  158. array("le",-16171),
  159. array("lei",-16169),
  160. array("leng",-16158),
  161. array("li" ,-16155),
  162. array("lia",-15959),
  163. array("lian",-15958),
  164. array("liang",-15944),
  165. array("liao",-15933),
  166. array("lie",-15920),
  167. array("lin",-15915),
  168. array("ling",-15903),
  169. array("liu",-15889),
  170. array("long", -15878),
  171. array("lou",-15707),
  172. array("lu",-15701),
  173. array("lv",-15681),
  174. array("luan",-15667),
  175. array ("lue",-15661),
  176. array("lun",-15659),
  177. array("luo",-15652),
  178. array("ma",-15640),
  179. array("mai",- 15631),
  180. array("man",-15625),
  181. array("mang",-15454),
  182. array("mao",-15448),
  183. array("me",-15436),
  184. array( "mei",-15435),
  185. array("men",-15419),
  186. array("meng",-15416),
  187. array("mi",-15408),
  188. array("mian",-15394 ),
  189. array("miao",-15385),
  190. array("mie",-15377),
  191. array("min",-15375),
  192. array("ming",-15369),
  193. array(" miu",-15363),
  194. array("mo",-15362),
  195. array("mou",-15183),
  196. array("mu",-15180),
  197. array("na",-15165) ,
  198. array("nai",-15158),
  199. array("name",-15153),
  200. array("name",-15150),
  201. array("nao",-15149),
  202. array("ne ",-15144),
  203. array("nei",-15143),
  204. array("nen",-15141),
  205. array("neng",-15140),
  206. array("ni",-15139),
  207. array("nian",-15128),
  208. array("niang",-15121),
  209. array("niao",-15119),
  210. array("nie",-15117),
  211. array("nin" ,-15110),
  212. array("ning",-15109),
  213. array("niu",-14941),
  214. array("nong",-14937),
  215. array("nu",-14933),
  216. array("nv",-14930),
  217. array("nuan",-14929),
  218. array("nue",-14928),
  219. array("nuo",-14926),
  220. array("o", -14922),
  221. array("ou",-14921),
  222. array("pa",-14914),
  223. array("pai",-14908),
  224. array("pan",-14902),
  225. array ("pang",-14894),
  226. array("pao",-14889),
  227. array("pei",-14882),
  228. array("pen",-14873),
  229. array("peng",- 14871),
  230. array("pi",-14857),
  231. array("pian",-14678),
  232. array("piao",-14674),
  233. array("pie",-14670),
  234. array( "pin",-14668),
  235. array("ping",-14663),
  236. array("po",-14654),
  237. array("pu",-14645),
  238. array("qi",-14630),
  239. array("qia",-14594),
  240. array("qian",-14429),
  241. array("qiang",-14407),
  242. array("qiao",-14399),
  243. array("qie",-14384),
  244. array("qin",-14379),
  245. array("qing",-14368),
  246. array("qiong",-14355),
  247. array("qiu",-14353),
  248. array("qu",-14345),
  249. array("quan",-14170),
  250. array("que",-14159),
  251. array("qun",-14151),
  252. array("ran",-14149),
  253. array("rang",-14145),
  254. array("rao",-14140),
  255. array("re",-14137),
  256. array("ren",-14135),
  257. array("reng",-14125),
  258. array("ri",-14123),
  259. array("rong",-14122),
  260. array("rou",-14112),
  261. array("ru",-14109),
  262. array("ruan",-14099),
  263. array("rui",-14097),
  264. array("run",-14094),
  265. array("ruo",-14092),
  266. array("sa",-14090),
  267. array("sai",-14087),
  268. array("san",-14083),
  269. array("sang",-13917),
  270. array("sao",-13914),
  271. array("se",-13910),
  272. array("sen",-13907),
  273. array("seng",-13906),
  274. array("sha",-13905),
  275. array("shai",-13896),
  276. array("shan",-13894),
  277. array("shang",-13878),
  278. array("shao",-13870),
  279. array("she",-13859),
  280. array("shen",-13847),
  281. array("sheng",-13831),
  282. array("shi",-13658),
  283. array("shou",-13611),
  284. array("shu",-13601),
  285. array("shua",-13406),
  286. array("shuai",-13404),
  287. array("shuan",-13400),
  288. array("shuang",-13398),
  289. array("shui",-13395),
  290. array("shun",-13391),
  291. array("shuo",-13387),
  292. array("si",-13383),
  293. array("song",-13367),
  294. array("sou",-13359),
  295. array("su",-13356),
  296. array("suan",-13343),
  297. array("sui",-13340),
  298. array("sun",-13329),
  299. array("suo",-13326),
  300. array("ta",-13318),
  301. array("tai",-13147),
  302. array("tan",-13138),
  303. array("tang",-13120),
  304. array("tao",-13107),
  305. array("te",-13096),
  306. array("teng",-13095),
  307. array("ti",-13091),
  308. array("tian",-13076),
  309. array("tiao",-13068),
  310. array("tie",-13063),
  311. array("ting",-13060),
  312. array("tong",-12888),
  313. array("tou",-12875),
  314. array("tu",-12871),
  315. array("tuan",-12860),
  316. array("tui",-12858),
  317. array("tun",-12852),
  318. array("tuo",-12849),
  319. array("wa",-12838),
  320. array("wai",-12831),
  321. array("wan",-12829),
  322. array("wang",-12812),
  323. array("wei",-12802),
  324. array("wen",-12607),
  325. array("weng",-12597),
  326. array("wo",-12594),
  327. array("wu",-12585),
  328. array("xi",-12556),
  329. array("xia",-12359),
  330. array("xian",-12346),
  331. array("xiang",-12320),
  332. array("xiao",-12300),
  333. array("xie",-12120),
  334. array("xin",-12099),
  335. array("xing",-12089),
  336. array("xiong",-12074),
  337. array("xiu",-12067),
  338. array("xu",-12058),
  339. array("xuan",-12039),
  340. array("xue",-11867),
  341. array("xun",-11861),
  342. array("ya",-11847),
  343. array("yan",-11831),
  344. array("yang",-11798),
  345. array("yao",-11781),
  346. array("ye",-11604),
  347. array("yi",-11589),
  348. array("yin",-11536),
  349. array("ying",-11358),
  350. array("yo",-11340),
  351. array("yong",-11339),
  352. array("you",-11324),
  353. array("yu",-11303),
  354. array("yuan",-11097),
  355. array("yue",-11077),
  356. array("yun",-11067),
  357. array("za",-11055),
  358. array("zai",-11052),
  359. array("zan",-11045),
  360. array("zang",-11041),
  361. array("zao",-11038),
  362. array("ze",-11024),
  363. array("zei",-11020),
  364. array("zen",-11019),
  365. array("zeng",-11018),
  366. array("zha",-11014),
  367. array("zhai",-10838),
  368. array("zhan",-10832),
  369. array("zhang",-10815),
  370. array("zhao",-10800),
  371. array("zhe",-10790),
  372. array("zhen",-10780),
  373. array("zheng",-10764),
  374. array("zhi",-10587),
  375. array("zhong",-10544),
  376. array("zhou",-10533),
  377. array("zhu",-10519),
  378. array("zhua",-10331),
  379. array("zhuai",-10329),
  380. array("zhuan",-10328),
  381. array("zhuang",-10322),
  382. array("zhui",-10315),
  383. array("zhun",-10309),
  384. array("zhuo",-10307),
  385. array("zi",-10296),
  386. array("zong",-10281),
  387. array("zou",-10274),
  388. array("zu",-10270),
  389. array("zuan",-10262),
  390. array("zui",-10260),
  391. array("zun",-10256),
  392. array("zuo",-10254)
  393. );
  394. function g($num){
  395. global $d;
  396. if($num>0&&$num<160){
  397. return chr($num);
  398. }
  399. elseif($num<-20319||$num>-10247){
  400. return "";
  401. }else{
  402. for($i=count($d)-1;$i>=0;$i--){
  403. if($d[$i][1]<=$num)break;
  404. }
  405. return $d[$i][0];
  406. }
  407. }
  408. function c($str){
  409. $ret="";
  410. for($i=0;$i $p=ord(substr($str,$i,1));
  411. if($p>160){
  412. $q=ord(substr($str,++$i,1));
  413. $p=$p*256+$q-65536;
  414. }
  415. $ret.=g($p);
  416. }
  417. return $ret;
  418. }
  419. echo ( substr( c("比特福"), 0, 1 ) );
  420. ?>
复制代码
首字母, php


Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template