How to convert numbers to uppercase by php
This article mainly shows you "php how to convert numbers to uppercase", the content is easy to understand, clear, hope to help you solve doubts, the following let the editor lead you to study and learn "php how to convert numbers to uppercase" this article.
1. Create a sample PHP file.
2. Define a "function cny ($ns) {...}" method.
3. Use cny and "_ cny_map_unit" methods for conversion.
Example
/ * lowercase to uppercase * @ param $ns int entered numbers * / function cny ($ns) {static $cnums = array ("zero", "one", "two", "three", "restaurant", "Wu", "Lu", "Qi", "Qing", "nine"), $cnyunits = array ("round", "corner", "cent"), $grees = array ("pick") "hundred", "thousand", "ten thousand", "pick up", "hundred", "thousand", "100 million") List ($ns1, $ns2) = explode (".", $ns, 2); $ns2 = array_filter (array ($ns2 [1], $ns2 [0])); $ret = array_merge ($ns2, array (implode (", _ cny_map_unit (str_split ($ns1), $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;} above is all the content of the article "how to convert numbers to uppercase". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!