Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does php convert numbers to uppercase

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly explains "how php converts numbers to uppercase". Interested friends may wish to take a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how php converts numbers to uppercase.

This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer

How to convert php numbers to uppercase? When we write the bill, we need to write the capitalization of the numerical amount. To be honest, we can't write it if we don't write it. In order to avoid embarrassing situations in the future, we specially practiced those ten words. Haha, of course, we can also convert it in php, so we have the following conversion function:

/ * 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;} so far, I believe you have a better understanding of "how php converts numbers to uppercase". Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report