php批量获取首字母(汉字、数字、英文)

作者&投稿:邓韩 (若有异议请与网页底部的电邮联系)

  php批量获取首字母(汉字 数字 英文)

  $mysql_server_name= ; //改成自己的mysql数据库服务器

  $mysql_username= 用户 ; //改成自己的mysql数据库用户名

  $mysql_password= 密码 ; //改成自己的mysql数据库密码

  $mysql_database= 数据库 ; //改成自己的mysql数据库名

  mysql_connect( $mysql_username $mysql_password) or die( database not access );

  mysql_select_db($mysql_database);

  mysql_query("SET NAMES utf ");

  $equery = " select title from 表 ";

  $result =mysql_query($equery );

  while ($row = mysql_fetch_array($result MYSQL_BOTH))

  {

  $title=$row["title"];

  if (ord($title)> ) { //汉字开头

  echo $letter=getfirstchar($title);

  }else if(ord($title)>= and ord($title)<= ){ //数字开头

  echo $letter=iconv_substr($title utf );

  }else if(ord($title)>= and ord($title)<= ){ //大写英文开头

  echo $letter=iconv_substr($title utf );

  }else if(ord($title)>= and ord($title)<= ){ //小写英文开头

  echo $letter=iconv_substr($title utf );

  }

  }

  function getfirstchar($s ){

  $s=iconv("UTF " "gb " $s );

  $asc=ord($s{ })* +ord($s{ }) ;

  if($asc>= and $asc<= )return "A";

  if($asc>= and $asc<= )return "B"; if($asc>= and $asc<= )return "C";

  if($asc>= and $asc<= )return "D";

  if($asc>= and $asc<= )return "E";

  if($asc>= and $asc<= )return "F";

  if($asc>= and $asc<= )return "G";

  if($asc>= and $asc<= )return "H";

  if($asc>= and $asc<= )return "J";

  if($asc>= and $asc<= )return "K";

  if($asc>= and $asc<= )return "L";

  if($asc>= and $asc<= )return "M";

  if($asc>= and $asc<= )return "N";

  if($asc>= and $asc<= )return "O";

  if($asc>= and $asc<= )return "P";

  if($asc>= and $asc<= )return "Q";

  if($asc>= and $asc<= )return "R";

  if($asc>= and $asc<= )return "S";

  if($asc>= and $asc<= )return "T";

  if($asc>= and $asc<= )return "W";

  if($asc>= and $asc<= )return "X";

  if($asc>= and $asc<= )return "Y";

  if($asc>= and $asc<= )return "Z";

  return false;

lishixinzhi/Article/program/PHP/201311/20913



~

可以用HP599一1铜棒代用用吗?
答:HPb59-1是铅黄铜,它的特点是可切削性好,有良好的力学性能,能承受冷.热压力加工,易焊接,钎焊好,对一般腐蚀有良好的稳定性,但有腐蚀破裂倾向,主要用于空调阀门、五金机械等。HPb59-1化学成分如下图:HPb59-1品牌首字母“H”表示黄铜,后两位数字表示黄铜的平均含量,最后的符号和数字表示元素...