php 获得汉字拼音首字母的函数,大家可以自行测试。
php获取汉字拼音的第一个字母
代码如下:
<?php
function getinitial($str)
{
$asc=ord(substr($str,0,1));
if ($asc<160) //非中文
{
if ($asc>=48 && $asc=65 && $asc=97 && $asc=176161 && $asc=176197 && $asc=178193 && $asc=180238 && $asc=182234 && $asc=183162 && $asc=184193 && $asc=185254 && $asc=187247 && $asc=191166 && $asc=192172 && $asc=194232 && $asc=196195 && $asc=197182 && $asc=197190 && $asc=198218 && $asc=200187 && $asc=200246 && $asc=203250 && $asc=205218 && $asc=206244 && $asc=209185 && $asc=212209){
return 'Z';
}else{
return '~';
}
}
}
echo getinitial("脚本");
?>
使用官方Model Context Protocol PHP SDK将PHP应用程序功能暴露为MCP工具、资源和提示,用于代理工作流。
代码如下:
function getfirstchar($s0){
$firstchar_ord=ord(strtoupper($s0{0}));
if (($firstchar_ord>=65 and $firstchar_ord=48 and $firstchar_ord=-20319 and $asc=-20283 and $asc=-19775 and $asc=-19218 and $asc=-18710 and $asc=-18526 and $asc=-18239 and $asc=-17922 and $asc=-17417 and $asc=-16474 and $asc=-16212 and $asc=-15640 and $asc=-15165 and $asc=-14922 and $asc=-14914 and $asc=-14630 and $asc=-14149 and $asc=-14090 and $asc=-13318 and $asc=-12838 and $asc=-12556 and $asc=-11847 and $asc=-11055 and $asc<p class="codebody"><br></p>
php免费学习视频:立即使用
踏上前端学习之旅,开启通往精通之路!从前端基础到项目实战,循序渐进,一步一个脚印,迈向巅峰!










