Last active
June 14, 2018 00:27
-
-
Save sola-msr/ea19a02cc25daca054395525a3a2f7a4 to your computer and use it in GitHub Desktop.
【PHP】空白を削除しつつ全角文字を半角文字に変換する ref: https://qiita.com/sola-msr/items/9798b01f7d6c2cd5d80e
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$code = ' ABC DEF G 1234 567 8 ABCD 12345 '; | |
$print = preg_replace('/( | )/', '', mb_convert_kana($code, 'a', 'UTF-8')); | |
var_dump($print); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string(24) "ABCDEFG12345678ABCD12345" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$code = ' ABC DEF G 1234 567 8 ABCD 12345 aaaああ ああ '; | |
$print = str_replace([' ',' '], '', mb_convert_kana($code, 'a', 'UTF-8')); | |
var_dump($print); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string(39) "ABCDEFG12345678ABCD12345aaaああああ" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment