...小写转换。首先我们先学习两个函数:strtoupper()函数和strtolower()函数将字符串全部转化为大写方法:strtoupper()函数strtoupper()函数是将字符串转化为大写、语法如...

例如:$str = '中华人民';

返回来 ZHRM;

下面是我百度的一个函数,但是有的情况会出错,例如: 重庆

返回来的是 ZQ

function getfirstchar($s0) {

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

if (($firstchar_ord >= 65 and $firstchar_ord <= 91)or ( $firstchar_ord >= 48 and $firstchar_ord <= 57))

return $s0{0};

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

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

if ($asc >= -20319 and $asc <= -20284)

return "A";

if ($asc >= -20283 and $asc <= -19776)

return "B";

if ($asc >= -19775 and $asc <= -19219)

return "C";

if ($asc >= -19218 and $asc <= -18711)

return "D";

if ($asc >= -18710 and $asc <= -18527)

return "E";

if ($asc >= -18526 and $asc <= -18240)

return "F";

if ($asc >= -18239 and $asc <= -17923)

return "G";

if ($asc >= -17922 and $asc <= -17418)

return "H";

if ($asc >= -17417 and $asc <= -16475)

return "J";

if ($asc >= -16474 and $asc <= -16213)

return "K";

if ($asc >= -16212 and $asc <= -15641)

return "L";

if ($asc >= -15640 and $asc <= -15166)

return "M";

if ($asc >= -15165 and $asc <= -14923)

return "N";

if ($asc >= -14922 and $asc <= -14915)

return "O";

if ($asc >= -14914 and $asc <= -14631)

return "P";

if ($asc >= -14630 and $asc <= -14150)

return "Q";

if ($asc >= -14149 and $asc <= -14091)

return "R";

if ($asc >= -14090 and $asc <= -13319)

return "S";

if ($asc >= -13318 and $asc <= -12839)

return "T";

if ($asc >= -12838 and $asc <= -12557)

return "W";

if ($asc >= -12556 and $asc <= -11848)

return "X";

if ($asc >= -11847 and $asc <= -11056)

return "Y";

if ($asc >= -11055 and $asc <= -10247)

return "Z";

return null;

}

回复内容:

例如:$str = '中华人民';

返回来 ZHRM;

下面是我百度的一个函数,但是有的情况会出错,例如: 重庆

返回来的是 ZQ

function getfirstchar($s0) {

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

if (($firstchar_ord >= 65 and $firstchar_ord <= 91)or ( $firstchar_ord >= 48 and $firstchar_ord <= 57))

return $s0{0};

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

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

if ($asc >= -20319 and $asc <= -20284)

return "A";

if ($asc >= -20283 and $asc <= -19776)

return "B";

if ($asc >= -19775 and $asc <= -19219)

return "C";

if ($asc >= -19218 and $asc <= -18711)

return "D";

if ($asc >= -18710 and $asc <= -18527)

return "E";

if ($asc >= -18526 and $asc <= -18240)

return "F";

if ($asc >= -18239 and $asc <= -17923)

return "G";

if ($asc >= -17922 and $asc <= -17418)

return "H";

if ($asc >= -17417 and $asc <= -16475)

return "J";

if ($asc >= -16474 and $asc <= -16213)

return "K";

if ($asc >= -16212 and $asc <= -15641)

return "L";

if ($asc >= -15640 and $asc <= -15166)

return "M";

if ($asc >= -15165 and $asc <= -14923)

return "N";

if ($asc >= -14922 and $asc <= -14915)

return "O";

if ($asc >= -14914 and $asc <= -14631)

return "P";

if ($asc >= -14630 and $asc <= -14150)

return "Q";

if ($asc >= -14149 and $asc <= -14091)

return "R";

if ($asc >= -14090 and $asc <= -13319)

return "S";

if ($asc >= -13318 and $asc <= -12839)

return "T";

if ($asc >= -12838 and $asc <= -12557)

return "W";

if ($asc >= -12556 and $asc <= -11848)

return "X";

if ($asc >= -11847 and $asc <= -11056)

return "Y";

if ($asc >= -11055 and $asc <= -10247)

return "Z";

return null;

}

可以尝试使用这个拼音库:

http://overtrue.me/pinyin/

http://overtrue.me/articles/2014/10/php-chinese-to-pinyin.html

可以使用 http://overtrue.me/pinyin/,开源项目

多音字没办法解决,除非你自己写枚举排除

...小写转换。首先我们先学习两个函数:strtoupper()函数和strtolower()函数将字符串全部转化为大写方法:strtoupper()函数strtoupper()函数是将字符串转化为大写、语法如...

...

本文介绍下,php中有关大小写转换函数strtolower、strtoupper用法,这在字符处理问题中经常遇到。有需要的朋友,参考下吧。

1,将字符串转换成小写

strtolower函数: 该函数将传入的字符串参数所有的字符都转换成小...

... if ($case == "upper")

{

$news .= strtoupper($ch);

}

elseif ($case == "low

strtoupper回导致中文乱码么本帖最后由 molaifeng 于 2013-11-25 09:04:16 编辑 在部署项目时,遇到一个奇怪的问题,页面打开后,php脚本嵌套在html页面里的部分出现乱码,数据库是没问题的。后来定位,发现问题...

在PHP中可以使用:strtoupper()函数、strtolower()函数、ucfirst()函数、lcfirst() 函数对字符串进行大小写处理。下面本篇文章就来给大家具体介绍一下,希望对大家有所帮助。strtoupper()函数strtouppe...

...ok){ foreach ($book->attributes as $attr) { echo strtoupper($attr->nodeName).' —— '.$attr->nodeValue.''; } echo "AU

...ews)."})",$show_news)) { $show_news="ALL"; }

if (strtoupper($show_news)=="ALL") { $sql="select date_format(n_date,'%m/%d/%Y') as n_date, date_form

...min_pwd = '$oldpwd'"); if(mysql_num_rows($result)!=0){ if(strtoupper($pwd) == strtoupper($re_pwd)){ $sql=mysql_query("SELECT admin_user,mob

...})",$show_news)) { $show_news="ALL"; } if (strtoupper($show_news)=="ALL") { $sql="select date_format(n_date,'%m/%d/%Y') as n_da

strtoupper() 函数把字符串转换为大写而strtolower函数: 该函数将传入的字符串参数所有的字符都转换成小写,并以小定形式放回这个字符串。下面通过本文给大家分享php大小写转换函数(strtolower、strtoupper)用法,需要的朋友参考下吧

php获取拼音首字母排序,php 如何获取字符串拼音首字母 - strtoupper相关推荐

  1. php获取中文城市首字母排序,PHP实现获取第一个中文首字母并进行排序的方法

    PHP实现获取第一个中文首字母并进行排序的方法 发布于 2017-08-10 07:47:28 | 108 次阅读 | 评论: 0 | 来源: 网友投递 PHP开源脚本语言PHP(外文名: Hyper ...

  2. android 字母排序i,Android 使用ListView的A-Z字母排序功能实现联系人模块

    在上一篇文章当中,主要学习了ListView的A-Z字母排序功能以及根据输入框的输入值改变来过滤搜索结果,如果输入框里面的值为空,更新为原来的列表,否则为过滤数据列表,包括汉字转成拼音的功能,如果你还 ...

  3. java 首字母小写_java实现将字符串中首字母转换成大写,其它全部转换成小写的方法示例...

    本文实例讲述了java实现将字符串中首字母转换成大写,其它全部转换成小写的方法.分享给大家供大家参考,具体如下: public class TestSubstring { public static ...

  4. 删除字符串的大写字母c语言,将字符串大写字母变小写 C语言 字符串中大小写字母转换...

    java怎样将大写字母转换成小写字母 具体代码如下,字符串中大.小写互转 1)输入 第一行只有一个整数m(m都说欲擒故纵最能虏获芳心,可小编拿什么对抗她在皱眉时,小编忍不住嘘寒问暖的情绪. jquer ...

  5. python判断字符是英文字母怎么回事_python判断字符串是否包含字母

    第一种方法:使用正则表达式判断字符串是否包含字母#-*- coding:utf-8 -*-import re def check(str): my_re = re.compile(r'[A-Za-z] ...

  6. android中文首字母排序,Android 实现中文按拼音排序方法

    难点:汉字转为拼音. https://github.com/promeG/TinyPinyin 是首先获取的Bean对象: for (int i = 0; i < dataList.size() ...

  7. android中文首字母排序,Android上汉字按拼音排序如何实现?

    具体的代码在 packages\providers\contactsprovider\src\com\android\providers\contacts\ContactL ocaleUtils.ja ...

  8. mysql 首字母排序_Mysql sql书写之——实现首字母从A-Z排序

    1.常规排序ASC DESC ASC 正序 DESC倒叙 -- 此处不用多讲 2.自定义排序 自定义排序是根据自己想要的特定字符串(数字)顺序进行排序.主要是使用函数 FIELD(str,str1,s ...

  9. java中按字母排序_如何在Java中按字母顺序对字符串进行排序

    使用toCharArray()方法 该类的toCharArray()方法将字符串转换为字符数组并返回它. 按字母顺序对字符串值进行排序获取所需的字符串. 使用toCharArray()方法将给定的字符 ...

最新文章

  1. 人脸识别技术在法国:质疑声中的先行者
  2. 关于类和对象的进一步讨论 C++
  3. IE9下iframe显示异常的处理方法
  4. C#正则表达式MatchCollection类浅析
  5. 字体大宝库:26款新鲜出炉的高品质免费英文字体
  6. 一键将Python2代码自动转化为Python3
  7. 前端学习(485):css
  8. 关于海康官网接口文档中:取流URL有效时间为5分钟表述歧义的说明
  9. 【AI视野·今日Sound 声学论文速览 第三期】Wed, 20 Apr 2022
  10. Phonetics: Lecture Three 语音 第三课 Teacher:Patrick
  11. Pytorch:损失函数
  12. Splash args 属性
  13. MacOS如何设置不使用时退出登录用户账号
  14. case when then else
  15. Mysql + keepalived 实现双主热备读写分离【转】
  16. 快播王欣发布匿名IM社交软件“马桶MT”
  17. 三相 AC-DC 变换电路(B 题)-- 2021 年全国大学生电子设计竞赛
  18. 财务共享中心计件需求
  19. 【报告分享】2021年网生代线上社交行为洞察报告-Mob研究院TT语音(附下载)
  20. 原神申鹤四星武器选哪个

热门文章

  1. 服务器显示拥挤进不去怎么办,《拥挤城市》游戏进不去怎么办 玩不了解决方法...
  2. 去除高清视频锯齿几个方法
  3. 九城卷入仙境传说2网游私服风波
  4. python入门基础笔记
  5. 解决uniapp用了textarea标签设置了边框,右边边框溢出手机屏幕问题
  6. Apache Camel入门教程
  7. 【计蒜客】蒜头君的旅游计划
  8. charles + 雷电模拟器4进行手机抓包
  9. 曲面着色器初试--地面轨迹模拟(部分细节不完善)
  10. 深度解读物联网区块链“IOTA”:不仅解决IoT痛点,还解决区块链痛点