PHP获取汉字拼音首字母
<FORM METHOD=POST ACTION="#">
<INPUT TYPE="text" NAME="name">
<INPUT TYPE="submit" value="query" name="sub">
</FORM>
<?php
function getinitial($str)
{
$asc=ord(substr($str,0,1)); //ord()获取ASCII
if ($asc<160) //非中文
{
if ($asc>=48 && $asc<=57){
return '1'; //数字
}elseif ($asc>=65 && $asc<=90){
return chr($asc); // A--Z chr将ASCII转换为字符
}elseif ($asc>=97 && $asc<=122){
return chr($asc-32); // a--z
}else{
return '~'; //其他
}
}
else //中文
{
$asc=$asc*1000+ord(substr($str,1,1));
//获取拼音首字母A--Z
if ($asc>=176161 && $asc<176197){
return 'A';
}elseif ($asc>=176197 && $asc<178193){
return 'B';
}elseif ($asc>=178193 && $asc<180238){
return 'C';
}elseif ($asc>=180238 && $asc<182234){
return 'D';
}elseif ($asc>=182234 && $asc<183162){
return 'E';
}elseif ($asc>=183162 && $asc<184193){
return 'F';
}elseif ($asc>=184193 && $asc<185254){
return 'G';
}elseif ($asc>=185254 && $asc<187247){
return 'H';
}elseif ($asc>=187247 && $asc<191166){
return 'J';
}elseif ($asc>=191166 && $asc<192172){
return 'K';
}elseif ($asc>=192172 && $asc<194232){
return 'L';
}elseif ($asc>=194232 && $asc<196195){
return 'M';
}elseif ($asc>=196195 && $asc<197182){
return 'N';
}elseif ($asc>=197182 && $asc<197190){
return 'O';
}elseif ($asc>=197190 &&
相关文档:
<?PHP
/**
* patServer
* PHP socket server base class
* Events that can be handled:
* * onStart
* * onConnect
* * onConnectionRefused
* * onClose
* * onShutdown
* * onReceiveData
*
* @version 1.1
* @author &n ......
www.diybl.com 时间:2008-06-01 作者:佚名
将其保存成一个文件,用时调用
<?
//为了避免重复包含文件而造成错误,加了判断函数是否存在的条件:
if(!function_exists(pageft)){
//定义函数pageft(),三个参数的含义为:
//$totle:信息总数;
//$displaypg:每页显示信息数,这里设置为默认是20;
//$url:分 ......
$xml = '../data/news.xml' ;
$qp = qp($xml, 'news_root')->children();
$arrData = array() ;
$i = 0 ;
foreach( $qp as $child )
{
print_r( $arrData );
echo "<br/>hi<br/>";
unset($arrSub);
$arrSub = array() ;
array_push( $arrData , &$arrSub );
print_r( $arrData ......
上次继本人发布了VC编写PHP扩展之Hello World篇后,反映很强烈,大家都希望能脱离PHP菜鸟行列,这次我给大家带来PHP调用C#编写的COM+组件。 COM+组件源代码 CODE:using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.Reflection; using System.Data.O ......
1、社团简介:
LAMP兄弟连社团(简称兄弟连)是易第优教育学院领导下的社团组织,是学院联系广大LAMP爱好者的桥梁和纽带,是学院社团管理协调的机构。
2、社团性质:
由LAMP兄弟连发起(www.lampbrother.net)的全国专业性、公益性社会沙龙组织。
3、社团目的:
a、为爱好LAMP的朋友们搭建一个学习交流的平台
b、为 ......