This article we mainly share the PHP conversion to uppercase function method, when we write to pay the bill, we need to fill in the amount of the number of capital, said that it is not really written to write, in order to not appear embarrassing scenes, but also deliberately to practice the 10 words. Haha, of course, we can also convert in PHP, so we have the following conversion function:
/** * Amount lowercase to uppercase * @param $ns int input number */function CNY ($ns) {Static $cnums = Array ( "0", "one", "II", "three", "the", "WU", "Lu", "Qi", "ba", "JIU", $cnyunits = Array ("Circle", "angle", "fen"), $grees = Array ("Pick", "Bai", "Thousand", " Million "," Pick "," Bai "," Qian "," billion "); List ($ns 1, $ns 2) = Explode (".", $ns, 2); $ns 2 = array_filter (Array ($ns 2[1], $ns 2[0])); $ret = Array_merge ($ns 2, Array (Implode ("", _cny_map_unit (Str_split ($ns 1), $grees)), ""); $ret = Implode ("", Array_reverse (_cny_map_unit ($ret, $CNYUNITSS))); Return Str_replace (Array_keys ($cnums), $cnums, $ret);} function _cny_map_unit ($list, $units) {$ul = count ($units); $xs = Array (); foreach (Array_reverse ($list) as $x) {$l = count ($xs); if ($x! = "0" | |! ( $l% 4) $n = ($x = = ' 0 '?) ": $x). ($units [($l-1)% $ul]); else $n = Is_numeric ($xs [0][0])? $x: "; Array_unshift ($xs, $n); } return $xs;}
View original >> Mamba children's shoes-blog-PHP numbers converted to uppercase functions
When we write to pay the bill, we need to fill in the number of capital, said that the real usually did not write it, in order to not appear embarrassing scenes, but also deliberately to practice the 10 words. Haha, of course, we can also convert in PHP, so we have the following conversion function:
/** * Amount lowercase to uppercase * @param $ns int input number */function CNY ($ns) {Static $cnums = Array ( "0", "one", "II", "three", "the", "WU", "Lu", "Qi", "ba", "JIU", $cnyunits = Array ("Circle", "angle", "fen"), $grees = Array ("Pick", "Bai", "Thousand", " Million "," Pick "," Bai "," Qian "," billion "); List ($ns 1, $ns 2) = Explode (".", $ns, 2); $ns 2 = array_filter (Array ($ns 2[1], $ns 2[0])); $ret = Array_merge ($ns 2, Array (Implode ("", _cny_map_unit (Str_split ($ns 1), $grees)), ""); $ret = Implode ("", Array_reverse (_cny_map_unit ($ret, $CNYUNITSS))); Return Str_replace (Array_keys ($cnums), $cnums, $ret);} function _cny_map_unit ($list, $units) {$ul = count ($units); $xs = Array (); foreach (Array_reverse ($list) as $x) {$l = count ($xs); if ($x! = "0" | |! ( $l% 4) $n = ($x = = ' 0 '?) ": $x). ($units [($l-1)% $ul]); else $n = Is_numeric ($xs [0][0])? $x: "; Array_unshift ($xs, $n); } return $xs;}