How do I filter characters such as the nickname obtained by qq interconnection?

Source: Internet
Author: User
By default, the qq account used by the website to register a new user is used to obtain the qq nickname as the user name. The Code $ user_array [& #039; member_name & #039;] $ qquser_info [& #039; nickname & #039;]; however, many QQ nicknames carry the symbol Mars, but website programs can only recognize numbers and Chinese characters... register a new user using qq
By default, qq nickname is obtained as the user name.
The Code is as follows:
$ User_array ['Member _ name'] = $ qquser_info ['nickname'];

However, many QQ nicknames contain symbols such as Mars, but website programs can only recognize numbers and Chinese characters,
How to filter the value of $ qquser_info ['nickname ']
Only the numbers and Chinese characters are retained.

For example, if the obtained QQ nickname is "fail", how can I filter the QQ nickname as "fail "?

Reply content:

Register a new user using qq
By default, qq nickname is obtained as the user name.
The Code is as follows:
$ User_array ['Member _ name'] = $ qquser_info ['nickname'];

However, many QQ nicknames contain symbols such as Mars, but website programs can only recognize numbers and Chinese characters,
How to filter the value of $ qquser_info ['nickname ']
Only the numbers and Chinese characters are retained.

For example, if the obtained QQ nickname is "fail", how can I filter the QQ nickname as "fail "?

$ Str = '* ^ % ☆ ☆as I am 123 then '; echo preg_replace ('| [^ a-zA-Z0-9 \ x {4e00}-\ x {9fa5}] | U', '', $ str );

Note,BytesThis character cannot be removed because it is a valid Chinese character.

The general practice is to first obtain the vertices of each word, and then determine whether the vertices are within the vertices range of Chinese characters or numbers. For the ranges of Chinese characters, see the link description.

Haha, I think it's right to let your website program recognize more content.

Try some pinyin libraries. It can be transferred. I don't know if I can meet duang.

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.