惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
B
Blog
S
SegmentFault 最新的问题
Vercel News
Vercel News
博客园 - 聂微东
宝玉的分享
宝玉的分享
C
Check Point Blog
有赞技术团队
有赞技术团队
IT之家
IT之家
V
V2EX
爱范儿
爱范儿
GbyAI
GbyAI
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Azure Blog
Microsoft Azure Blog
P
Proofpoint News Feed
博客园 - 司徒正美
博客园_首页
Last Week in AI
Last Week in AI
博客园 - 叶小钗
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
F
Fortinet All Blogs
腾讯CDC
J
Java Code Geeks

博客园 - 古代

linux下关于重命名卷标 wget header参数使用。 - 古代 - 博客园 奔波尔霸温瑞安 方娥真〈月台〉析论 入凡尘十二年的方娥真 模拟兼容onmouseleave,onmouseenter - 古代 - 博客园 python 进程通信测试代码(程序A,程序B) parse_url 和再pathinfo,what you'll get - 古代 autopos RPM 安装mod_encoding,linux下apache支持中文名 自动杀死pps的后台进程 js表达式转义 - 古代 - 博客园 批量jstest get_top_dom($dom); - 古代 - 博客园 rm大量文件 Read-only file system处理记录 通过PHP获取生僻字的汉语拼音[转] 唉,这个备案,头疼. 神奇的js代码,图片全都飞起来了
php转换拼音,全。
古代 · 2010-03-11 · via 博客园 - 古代

global $pinyindata;
$pinyindata = file_get_contents( dirname(__FILE__).'/WINPY.TXT') ;
function pinyin($str , $type='all')
{
 global $pinyindata;
 $ret = '' ;
 $data = $pinyindata;
 for($i=0;$i<strlen($str);$i++){
   if(ord($str[$i])>0x80){
   $c = $str[$i].$str[++$i];
   $frompos = strpos($data , $c) ;
   if($frompos){
    $topos = strpos($data,"\n",$frompos+strlen($c));
    $start = $frompos+strlen($c);
    $end = $topos-$start;
    $txt = substr($data,$start,$end);
    if($type=='all'){
     $ret .= $txt ;
    }else if($type=='first'){
     $ret .=substr($txt , 0 , 1) ;
    }
   }
   }else{
  $ret .=$str[$i] ;
   }
 }
 return $ret ;
}