Created
October 23, 2012 03:52
-
-
Save dca/3936520 to your computer and use it in GitHub Desktop.
PHP n2str
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 | |
| /** | |
| * @Function n2str | |
| * | |
| * 數字轉字串 | |
| * | |
| * @param String 原始數字字串 | |
| * @param Boolean 功能反轉 | |
| * @return String 中文字串 | |
| */ | |
| function n2str($n, $inverse = false ) | |
| { | |
| $str = array('一','二','三','四','五','六','七','八','九','零' ); | |
| $num = array('1','2','3','4','5','6','7','8','9','0' ); | |
| if ( !($inverse) ) { | |
| return str_replace($num,$str,$n); | |
| } else{ | |
| return str_replace($str,$num,$n); | |
| } | |
| return 'n2str error'; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment