In this article, I will introduce how to use PHP to extract the first letter of Chinese and English words and numbers. If you need a friend, refer to the recent project and have a need to extract the first letter of each word from a massive dictionary of Chinese and English (including Arabic numerals 0-9:
Gannicus --> G
Free --> Z
2B --> E
Silly X --> S The code is as follows:Private function getfirstchar ($ s0 ){$ S = iconv ('utf-8', 'gb2312', $ s0 );If (ord ($ s0)> 128) {// starts with a Chin
I need to write a script recently. I need to get the first letter of Chinese characters and pinyin. I checked some materials online and found it is easy to implement. I would like to share it with you. This script is used for the first letter of Chinese Characters in pinyin, for example, "I am a Chinese". The resulting letter is wszgr.
#! /Usr/bin/env python
#-*-Coding: UTF-8 -*-
Def multi_get_letter (str_input ):
If isinstance (str_input, unicode ):
Unicode_str = str_input
El
PHP is used to obtain the first letter in Chinese and English. PHP is used to obtain the first letter in Chinese and English. This article is a simple method and example of extracting the first letter in Chinese and English characters using php. it is very useful. if you need it, you can use PHP to obtain the first letter in Chinese and English.
This article will share with you how to use php to extract the first letter of Chinese and English characters.
PHP to obtain the first letter in Chines
Remove the first letter function
function Getfirstchar ($s 0) {if (Ord ($s 0) >= "1" and Ord ($s 0) $s =iconv ("UTF-8", "gb2312", $s 0); If you need to convert to Utf-8.$s = $s 0;//without conversion$asc =ord ($s {0}) *256+ord ($s {1})-65536;if ($asc >=-20319 and $asc if ($asc >=-20283 and $
The first letter of Chinese characters in php to pinyin. After running the program, some characters in the string cannot be converted. If you enter these words separately, you can directly convert them to read the first letter of the alphabet. It won't work in the string. The program code is as follows: nbsp; lt ;? Php nbsp; function nbsp; getfirstchar ($ s0) { nbsp; nbsp php Chinese character to pinyin first letter problem.
After running the program, some characters in the string cannot be
PHP: how to obtain letters on the Chinese homepage
Function getfirstchar ($ s0 ){
$ Fchar = ord (substr ($ s0, 0, 1 ));
If ($ fchar> = ord ("a") and $ fchar
$ S = iconv ("UTF-8", "gb2312", $ s0 );
$ Asc = ord ($ s {0}) * 256 + ord ($ s Beckham)-65536;
If ($ asc >=- 20319 and $ asc
If ($
The first letter of Chinese characters in php to pinyin. PHP obtains the first letter of pinyin.
After running the program, some characters in the string cannot be converted. If you enter these words separately, you can directly convert them to read the first letter of the alphabet.
It won't work in the string. The program code is as follows:
Function getfirstchar ($ s0 ){
$ Fchar = ord ($ s0 {0 });
If ($ fchar> = ord ("a") and $ fchar
$ S1 = iconv ("UTF-8", "gb2312", $ s0 );
$ S2 =
$ firstchar_ord
// $ S = iconv ("UTF-8", "gb2312", $ s0 );
$ S = $ s0;
$ Asc = ord ($ s {0}) * 256 + ord ($ s {1})-65536;
If ($ asc >=- 20319 and $ asc
If ($ asc >=- 20283 and $ asc
If ($ asc >=- 19775 and $
In the project encountered the need to put the game in alphabetical order, so Baidu to a formatted initial letter method. /** * @name php get Chinese characters Pinyin first letter * @param $str * @return null|string*/ Public functionGetfirstcharter ($str) { if(Empty($str)) { return‘‘; } $fchar=Ord($str{0}); if($fchar>=Ord(' A ') $fcharOrd(' Z ')) { return Strtoupper($str{0}); } $s 1=Iconv(' UTF-8 ', ' gb2312 ',$str); $s 2=Iconv(' gb2312 ', '
The method used in the development, take out the first letter of a Chinese character;/** * Take the first letter of Chinese character * @param string $str * @return String|null*/functionGetfirstchar ($str) { if(Empty($str)) { return‘‘; } $fir=$fchar=Ord($str[0]); if($fchar>=Ord(' A ') $fcharOrd(' Z ')) { return Strtoupper($str[0]); } $s 1= @Iconv(' UTF-8 ', ' gb2312 ',$str); $s 2= @Iconv(' gb2312 ', ' UTF-8 ',$s 1); $s=$s 2==$str?$s 1:$str; if(!isset($s[0]) | | !isset($s[1
) {
$s =iconv ("UTF-8", "gb2312", $s 0);
$asc =ord ($s {0}) *256+ord ($s {1})-65536;
if ($asc >=-20319 and $asc
if ($asc >=-20283 and $asc
if ($asc >=-19218 and $asc
if ($
)([emailprotected]) [test]> insert into l values (3,4,14,20);hang~~~Session1:([emailprotected]) [(none)]> show engine innodb status\G...MySQL thread id 1087, OS thread handle 139830446065408, query id 7300 localhost root updateinsert into l values (3,4,14,20)------- TRX HAS BEEN WAITING 19 SEC FOR THIS LOCK TO BE GRANTED:RECORD LOCKS space id 1358 page no 5 n bits 72 index b of table `test`.`l` trx id 31220594 lock_mode X locks gap before rec insert intention waitingRecord lock, heap no 3 PHYSIC
1> Many PHP tool classes on the network can convert Chinese characters to pinyin;2> to sort the pinyinThe other is similar to the MySQL transcoding method:1foreach($array as $key=$value) 2 { 3$new _array[$key] =Iconv(' UTF-8 ', ' GBK ',$value); 4} 1foreach($array as $key=$value) 2 { 3$new _array[$key] =Iconv(' UTF-8 ', ' GBK ',$value); 4 } 5Asort($new _array); 6foreach($new _array as $key=$value) 7 { 8$array[$key] =Iconv(' GBK ', ' UTF-8 ',$value); 9 } 5Asort($new _
1. MySQL is sorted by the first letter of the pinyin Field Value
Keywords binary: selectName from topic order bybinary name ASC
2. Obtain the first letter of Chinese pinyin in PHP.
Directly call the following function. For example, Echo getinitial ("Dan ");
Function getinitial ($ Str){$ ASC = ord (substr ($ STR, 0, 1 ));If ($ ASC {If ($
The example is as follows: When I used show InnoDB status to check the engine status, I found a deadlock problem: * ** (1) transaction: Transaction 0 677833455, active 0 sec, process no 11393, OS thread ID 278546 starting index read MySQL tables in use 1, locked 1 Lock wait3 lock struct (s), heap size 320 MySQL thread ID 83, query ID 162348740 dcnet03 dcnet searching rows for update Update tsk_task set status_id = 1064, update_time = now () Where status_id = 1061 and mon_time
* **
Recently, in the project development process, encountered the database deadlock problem, in the process of solving the problem, the author of the MySQL InnoDB engine lock mechanism understanding gradually deepened.
The case is as follows:
The deadlock problem was found when using show InnoDB status to check engine state:
(1) TRANSACTION:TRANSACTION 0 677833455, ACTIVE 0 sec, Process no 11393, OS thread ID 278546 starting index readMySQL tables in use 1, locked 1Lock wait 3 lock struct (s), He
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.