// 半角数组 $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,'テスト')); // 全角转半角
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.