> 백엔드 개발 > PHP 튜토리얼 > php获取汉字首字母

php获取汉字首字母

WBOY
풀어 주다: 2016-07-25 08:42:04
원래의
1558명이 탐색했습니다.

php获取首字母

[PHP]代码

  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("ka",-16474),
  141. array("kai",-16470),
  142. array("kan",-16465),
  143. array("kang",-16459),
  144. array("kao",-16452),
  145. array("ke",-16448),
  146. array("ken",-16433),
  147. array("keng",-16429),
  148. array("kong",-16427),
  149. array("kou",-16423),
  150. array("ku",-16419),
  151. array("kua",-16412),
  152. array("kuai",-16407),
  153. array("kuan",-16403),
  154. array("kuang",-16401),
  155. array("kui",-16393),
  156. array("kun",-16220),
  157. array("kuo",-16216),
  158. array("la",-16212),
  159. array("lai",-16205),
  160. array("lan",-16202),
  161. array("lang",-16187),
  162. array("lao",-16180),
  163. array("le",-16171),
  164. array("lei",-16169),
  165. array("leng",-16158),
  166. array("li",-16155),
  167. array("lia",-15959),
  168. array("lian",-15958),
  169. array("liang",-15944),
  170. array("liao",-15933),
  171. array("lie",-15920),
  172. array("lin",-15915),
  173. array("ling",-15903),
  174. array("liu",-15889),
  175. array("long",-15878),
  176. array("lou",-15707),
  177. array("lu",-15701),
  178. array("lv",-15681),
  179. array("luan",-15667),
  180. array("lue",-15661),
  181. array("lun",-15659),
  182. array("luo",-15652),
  183. array("ma",-15640),
  184. array("mai",-15631),
  185. array("man",-15625),
  186. array("mang",-15454),
  187. array("mao",-15448),
  188. array("me",-15436),
  189. array("mei",-15435),
  190. array("men",-15419),
  191. array("meng",-15416),
  192. array("mi",-15408),
  193. array("mian",-15394),
  194. array("miao",-15385),
  195. array("mie",-15377),
  196. array("min",-15375),
  197. array("ming",-15369),
  198. array("miu",-15363),
  199. array("mo",-15362),
  200. array("mou",-15183),
  201. array("mu",-15180),
  202. array("na",-15165),
  203. array("nai",-15158),
  204. array("nan",-15153),
  205. array("nang",-15150),
  206. array("nao",-15149),
  207. array("ne",-15144),
  208. array("nei",-15143),
  209. array("nen",-15141),
  210. array("neng",-15140),
  211. array("ni",-15139),
  212. array("nian",-15128),
  213. array("niang",-15121),
  214. array("niao",-15119),
  215. array("nie",-15117),
  216. array("nin",-15110),
  217. array("ning",-15109),
  218. array("niu",-14941),
  219. array("nong",-14937),
  220. array("nu",-14933),
  221. array("nv",-14930),
  222. array("nuan",-14929),
  223. array("nue",-14928),
  224. array("nuo",-14926),
  225. array("o",-14922),
  226. array("ou",-14921),
  227. array("pa",-14914),
  228. array("pai",-14908),
  229. array("pan",-14902),
  230. array("pang",-14894),
  231. array("pao",-14889),
  232. array("pei",-14882),
  233. array("pen",-14873),
  234. array("peng",-14871),
  235. array("pi",-14857),
  236. array("pian",-14678),
  237. array("piao",-14674),
  238. array("pie",-14670),
  239. array("pin",-14668),
  240. array("ping",-14663),
  241. array("po",-14654),
  242. array("pu",-14645),
  243. array("qi",-14630),
  244. array("qia",-14594),
  245. array("qian",-14429),
  246. array("qiang",-14407),
  247. array("qiao",-14399),
  248. array("qie",-14384),
  249. array("qin",-14379),
  250. array("qing",-14368),
  251. array("qiong",-14355),
  252. array("qiu",-14353),
  253. array("qu",-14345),
  254. array("quan",-14170),
  255. array("que",-14159),
  256. array("qun",-14151),
  257. array("ran",-14149),
  258. array("rang",-14145),
  259. array("rao",-14140),
  260. array("re",-14137),
  261. array("ren",-14135),
  262. array("reng",-14125),
  263. array("ri",-14123),
  264. array("rong",-14122),
  265. array("rou",-14112),
  266. array("ru",-14109),
  267. array("ruan",-14099),
  268. array("rui",-14097),
  269. array("run",-14094),
  270. array("ruo",-14092),
  271. array("sa",-14090),
  272. array("sai",-14087),
  273. array("san",-14083),
  274. array("sang",-13917),
  275. array("sao",-13914),
  276. array("se",-13910),
  277. array("sen",-13907),
  278. array("seng",-13906),
  279. array("sha",-13905),
  280. array("shai",-13896),
  281. array("shan",-13894),
  282. array("shang",-13878),
  283. array("shao",-13870),
  284. array("she",-13859),
  285. array("shen",-13847),
  286. array("sheng",-13831),
  287. array("shi",-13658),
  288. array("shou",-13611),
  289. array("shu",-13601),
  290. array("shua",-13406),
  291. array("shuai",-13404),
  292. array("shuan",-13400),
  293. array("shuang",-13398),
  294. array("shui",-13395),
  295. array("shun",-13391),
  296. array("shuo",-13387),
  297. array("si",-13383),
  298. array("song",-13367),
  299. array("sou",-13359),
  300. array("su",-13356),
  301. array("suan",-13343),
  302. array("sui",-13340),
  303. array("sun",-13329),
  304. array("suo",-13326),
  305. array("ta",-13318),
  306. array("tai",-13147),
  307. array("tan",-13138),
  308. array("tang",-13120),
  309. array("tao",-13107),
  310. array("te",-13096),
  311. array("teng",-13095),
  312. array("ti",-13091),
  313. array("tian",-13076),
  314. array("tiao",-13068),
  315. array("tie",-13063),
  316. array("ting",-13060),
  317. array("tong",-12888),
  318. array("tou",-12875),
  319. array("tu",-12871),
  320. array("tuan",-12860),
  321. array("tui",-12858),
  322. array("tun",-12852),
  323. array("tuo",-12849),
  324. array("wa",-12838),
  325. array("wai",-12831),
  326. array("wan",-12829),
  327. array("wang",-12812),
  328. array("wei",-12802),
  329. array("wen",-12607),
  330. array("weng",-12597),
  331. array("wo",-12594),
  332. array("wu",-12585),
  333. array("xi",-12556),
  334. array("xia",-12359),
  335. array("xian",-12346),
  336. array("xiang",-12320),
  337. array("xiao",-12300),
  338. array("xie",-12120),
  339. array("xin",-12099),
  340. array("xing",-12089),
  341. array("xiong",-12074),
  342. array("xiu",-12067),
  343. array("xu",-12058),
  344. array("xuan",-12039),
  345. array("xue",-11867),
  346. array("xun",-11861),
  347. array("ya",-11847),
  348. array("yan",-11831),
  349. array("yang",-11798),
  350. array("yao",-11781),
  351. array("ye",-11604),
  352. array("yi",-11589),
  353. array("yin",-11536),
  354. array("ying",-11358),
  355. array("yo",-11340),
  356. array("yong",-11339),
  357. array("you",-11324),
  358. array("yu",-11303),
  359. array("yuan",-11097),
  360. array("yue",-11077),
  361. array("yun",-11067),
  362. array("za",-11055),
  363. array("zai",-11052),
  364. array("zan",-11045),
  365. array("zang",-11041),
  366. array("zao",-11038),
  367. array("ze",-11024),
  368. array("zei",-11020),
  369. array("zen",-11019),
  370. array("zeng",-11018),
  371. array("zha",-11014),
  372. array("zhai",-10838),
  373. array("zhan",-10832),
  374. array("zhang",-10815),
  375. array("zhao",-10800),
  376. array("zhe",-10790),
  377. array("zhen",-10780),
  378. array("zheng",-10764),
  379. array("zhi",-10587),
  380. array("zhong",-10544),
  381. array("zhou",-10533),
  382. array("zhu",-10519),
  383. array("zhua",-10331),
  384. array("zhuai",-10329),
  385. array("zhuan",-10328),
  386. array("zhuang",-10322),
  387. array("zhui",-10315),
  388. array("zhun",-10309),
  389. array("zhuo",-10307),
  390. array("zi",-10296),
  391. array("zong",-10281),
  392. array("zou",-10274),
  393. array("zu",-10270),
  394. array("zuan",-10262),
  395. array("zui",-10260),
  396. array("zun",-10256),
  397. array("zuo",-10254)
  398. );
  399. function g($num){
  400. global $d;
  401. if($num>0&&$num return chr($num);
  402. }
  403. elseif($num-10247){
  404. return "";
  405. }else{
  406. for($i=count($d)-1;$i>=0;$i--){
  407. if($d[$i][1] }
  408. return $d[$i][0];
  409. }
  410. }
  411. function c($str){
  412. $ret="";
  413. for($i=0;$i $p=ord(substr($str,$i,1));
  414. if($p>160){
  415. $q=ord(substr($str,++$i,1));
  416. $p=$p*256+$q-65536;
  417. }
  418. $ret.=g($p);
  419. }
  420. return $ret;
  421. }
  422. echo ( substr( c("比特福"), 0, 1 ) );
  423. ?>
复制代码
首字母, php


관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿