Skip to content

Instantly share code, notes, and snippets.

@dca
Created October 23, 2012 03:52
Show Gist options
  • Select an option

  • Save dca/3936520 to your computer and use it in GitHub Desktop.

Select an option

Save dca/3936520 to your computer and use it in GitHub Desktop.
PHP n2str
<?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