Full and half-width conversion in php

WBOY
Release: 2016-07-30 13:29:26
Original
860 people have browsed it
// 半角数组 
$half = array(
   '0','1','2','3','4','5',
   '6','7','8','9','a','b',
   'c','d','e','f','g','h',
   'i','j','k','l','m','n',
   'o','p','q','r','s','t',
   'u','v','w','x','y','z',
   'A','B','C','D','E','F',
   'G','H','I','J','K','L',
   'M','N','O','P','Q','R',
   'S','T','U','V','W','X',
   'Y','Z','-','_','.','@',
   '?','?','?','?','?','?','?',
   '?','?','?','?','?','?','?',
   '?','?','?','?','?','?','?',
   '?','?','ネ','?','?','?','?',
   '?','?','?','?','ム','?','?',
   '?','?','?','?','?','?','?',
   '?','?','?'
 );
//全角数组
 $full = array(
   '0','1','2','3','4','5',
   '6','7','8','9','a','b',
   'c','d','e','f','g','h',
   'i','j','k','l','m','n',
   'o','p','q','r','s','t',
   'u','v','w','x','y','z',
   'A','B','C','D','E','F',
   'G','H','I','J','K','L',
   'M','N','O','P','Q','R',
   'S','T','U','V','W','X',
   'Y','Z','-','_','.','@',
   'ア','イ','ウ','エ','オ','カ','キ',
   'ク','ケ','コ','サ','シ','ス','セ',
   'ソ','タ','チ','ツ','テ','ト','ナ',
   'ニ','ヌ','ネ','ノ','ハ','ヒ','フ',
   'ヘ','ホ','マ','ミ','ム','メ','モ',
   'ヤ','イ','ユ','エ','ヨ','ラ','リ',
   'ル','レ','ロ',
 );
  var_dump(str_replace($half, $full, '???')); // 半角转全角
  var_dump(str_replace($full,$half,'テスト')); // 全角转半角
Copy after login

The above introduces the full-width and half-width conversion in PHP, including the relevant aspects. 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!