PHP function to remove the first letter of a string (including Chinese characters)

WBOY
Release: 2016-07-29 09:10:38
Original
1300 people have browsed it

//Get the first letter function

function getfirstchar($s0){
if(ord($s0)>="1" and ord($s0)<=ord("z") ) { return strtoupper($s0); }
//$s=iconv("UTF-8", "gb2312", $s0); If you need to convert to utf-8
$s=$s0;//No need Conversion situation
$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>=-16212 and $asc<=-15641)return "L"; -15165 and $asc<=-14923)return "N"; < = -14631) Return "P";
IF ($ ASC & GT; = -14630 and $ ASC & LT; = -14150) Return "q";
if ($ asc & gt; =-14149 and $ asc & lt; =-1409111140911 ) Return " R"; "        
if( $asc>=-12838 and $asc<=-12557)return "W"; 847 and $asc<=-11056)return "Y";
if($asc>=-11055 and $asc<=-10247)return "Z"; ;

?>

The above introduces the PHP function for extracting the first letter of a string (including Chinese characters), including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!