Home > php教程 > php手册 > body text

用php获取汉字拼音首字母的方法

WBOY
Release: 2016-06-06 19:50:54
Original
1104 people have browsed it

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入 用php获取汉字拼音首字母,如:自学网得到Z首字母。 代码如下:?php function getfirstchar($s0){ $firstchar_ord=ord(strtoupper($s0{0})); if (($firstchar_ord=65 and $firstchar_ord=91

欢迎进入Linux社区论坛,与200万技术人员互动交流 >>进入

  用php获取汉字拼音首字母,如:自学网得到Z首字母。

  代码如下:

  function getfirstchar($s0){

  $firstchar_ord=ord(strtoupper($s0{0}));

  if (($firstchar_ord>=65 and $firstchar_ord=48 and $firstchar_ord

  //$s=iconv("UTF-8","gb2312", $s0);

  $s=$s0;

  $asc=ord($s{0})*256+ord($s{1})-65536;

  if($asc>=-20319 and $asc

  if($asc>=-20283 and $asc

  if($asc>=-19775 and $asc

  if($asc>=-19218 and $asc

  if($asc>=-18710 and $asc

  if($asc>=-18526 and $asc

  if($asc>=-18239 and $asc

  if($asc>=-17922 and $asc

  if($asc>=-17417 and $asc

  if($asc>=-16474 and $asc

  if($asc>=-16212 and $asc

  if($asc>=-15640 and $asc

  if($asc>=-15165 and $asc

  if($asc>=-14922 and $asc

  if($asc>=-14914 and $asc

  if($asc>=-14630 and $asc

  if($asc>=-14149 and $asc

  if($asc>=-14090 and $asc

  if($asc>=-13318 and $asc

  if($asc>=-12838 and $asc

  if($asc>=-12556 and $asc

  if($asc>=-11847 and $asc

  if($asc>=-11055 and $asc

  return null;

  }

  var_dump(getfirstchar("自学网"));

  ?>

用php获取汉字拼音首字母的方法

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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template