小編給大家分享一下php漢字轉(zhuǎn)首字母大寫的方法是什么,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
專注于為中小企業(yè)提供成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)服務(wù),電腦端+手機(jī)端+微信端的三站合一,更高效的管理,為中小企業(yè)高明免費(fèi)做網(wǎng)站提供優(yōu)質(zhì)的服務(wù)。我們立足成都,凝聚了一批互聯(lián)網(wǎng)行業(yè)人才,有力地推動(dòng)了1000+企業(yè)的穩(wěn)健成長,幫助中小企業(yè)通過網(wǎng)站建設(shè)實(shí)現(xiàn)規(guī)模擴(kuò)充和轉(zhuǎn)變。
php漢字轉(zhuǎn)首字母大寫的實(shí)現(xiàn)方法:首先創(chuàng)建一個(gè)PHP示例文件;然后定義一個(gè)“getfirstchar”方法用于獲取漢字拼音且將首字母轉(zhuǎn)為大寫;最后通過echo輸出轉(zhuǎn)換結(jié)果即可。
PHP 獲取漢字拼音首字母大寫
= ord("a") and $fchar <= ord("z"))or($fchar >= ord("A") and $fchar <= ord("Z"))) return strtoupper(chr($fchar)); $s = iconv("UTF-8", "GBK", $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; } function mb_str_split($string) { return preg_split('/(?
結(jié)果:
SCP
以上是php漢字轉(zhuǎn)首字母大寫的方法是什么的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對(duì)大家有所幫助,如果還想學(xué)習(xí)更多知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!