PHP converts full-width characters in a string to half-width characters _php tutorial

Source: Internet
Author: User
Tags array to string string to json

PHP converts full-width characters in a string to half-width characters


PHP converts full-width characters in a string to half-width characters, excerpted from Ecshop.

/** * Converts a string containing full-width numeric characters, letters, spaces, or '%+-() ' characters to corresponding half-width characters * @access public * @param string $str to be converted String * @return str  ing $str processed string */function make_semiangle ($str) {$arr = array (' 0 ' = ' 0 ', ' 1 ' = ' 1 ', ' 2 ' = ' 2 ',                 ' 3 ' = ' 3 ', ' 4 ' = ' 4 ', ' 5 ' = ' 5 ', ' 6 ' = ' 6 ', ' 7 ' = ' 7 ', ' 8 ' = ' 8 ', ' 9 ' = ' 9 ', ' A ' = ' a ', ' B ' = ' B ', ' c ' = ' C ', ' d ', ' = ' d ', ' e ' + ' e ', ' f ' = ' f ', ' g ' = ' = ' g ', ' h ' = ' h ', ' i ' = = ' I ', ' j ' = ' j ', ' k ' = ' k ', ' l ' = ' + ', '-' = ', ' m ', '                 n ' + ' n ', ' o ' = ' o ', ' p ' = = ' P ', ' q ' + = ' q ', ' r ' = ' + ' r ', ' s ' = ' = ', ' + ' and ' t ', ' u ' + = ' u ', ' v ' = = ' V ', ' w ' = = ' W ', ' x ' + ' x ', ' y ' = = ' y ', ' z ' = ' = ', ' a '  ' = ' A ', ' b ' = ' = ' B ', ' c ' = ' C ', ' d ' = = ' d ', ' e ' = ' e ', ' f ' = ' = ' f ', ' g ' = = ' g ', ' H ' = ' h ', ' i ' + = ' I', ' j ' = ' j ', ' k ' = ' k ', ' l ' = ' ' l ', ' m ' = = ' m ', ' n ' = ' n ', ' o ' = ' o ' ', ' p ' = ' P ', ' q ' + = ' q ', ' r ' = ' R ', ' s ' = = ' s ', ' t ' and ' t ', ' u ' = ' u ', ' V ' = ' V ' , ' w ' = ' W ', ' x ' = ' x ', ' y ' = ' y ', ' z ' + ' z ', ' (' + = ' (', ') ' = ') '  , ' (' = ' + ' [', ') ' + '] ', ' ' ' ' + ' [', ' ' ' ' ' + '] ', ' ' ' = ' ' [', ' ' ' + '] ', ' ' ' ' = ' [',                 ' ' = ' = ', ' ' = ', ' ' = ', ' ' = ', ' ' = ', ' ' = ', ' ' = ', ' ' = ', ' ' = ', ' ' = ', ' = ', ' ' +                 ' ' = ' > ', '% ' = '% ', ' + ' + ' + ', '-' = '-', '-' = '-', ' ~ ' = '-', ': ' = ': ', '. ' = = ', ', ', ' = = ', ', ', ' = ', ', ', ' = ', ', '; ' = ', ', '? ' = = '? ', '! ' = = '! ', ' ... ' + '-', ' ‖ ' and ' | ', ' ' ' ' + ' ', ' ' ' ' + ' ', ' ' ' ' ' ' = ' and ',                "' = = '); Return Strtr ($str, $arr);}

Articles you may be interested in

    • PHP converts consecutive spaces in a string to a space
    • How PHP converts BR newline characters in HTML to line breaks in text input
    • JS How to convert the returned string to JSON-formatted data
    • MySQL query with single quotation mark string and insert with single quote string need to pay attention to the problem
    • PHP to determine whether the string is in English, pure Chinese, the method of combination of English
    • PHP functions convert 16 color codes to RGB color values
    • PHP gets the character length of the UTF8 string
    • JS array to string, JS string to array method summary

http://www.bkjia.com/PHPjc/999259.html www.bkjia.com true http://www.bkjia.com/PHPjc/999259.html techarticle PHP converts full-width characters in a string to half-width characters php converts full-width characters in a string to half-width characters, and is excerpted from Ecshop. /** * A string containing full-width numeric characters, letters ...

  • 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.