Rumah > Artikel > pembangunan bahagian belakang > php 中全半角转换
// 半角数组 $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,'テスト')); // 全角转半角
以上就介绍了php 中全半角转换,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。