Table of Contents
一个阿拉伯数字转中文数字的函数,阿拉伯中文
Excel 2010怎把阿拉伯数字转成中文大写数字?(不要函数,有没有工具直接转换)
在excel中 怎将中文表示的数字转换为阿拉伯数字??
Home php教程 php手册 一个阿拉伯数字转中文数字的函数,阿拉伯中文

一个阿拉伯数字转中文数字的函数,阿拉伯中文

Jun 13, 2016 am 09:29 AM
Chinese function number most of change need

一个阿拉伯数字转中文数字的函数,阿拉伯中文

 

最近因需要,写了个“阿拉伯数字转中文数字的函数”。搜索了精华区只见到一个类似的。
感觉到我的算法不错,所以贴出来共享一下如果要用于金额的转换,对小数部分的处理要做一下修改
function ch_num($num,$mode=true) {
  $char = array("零","壹","贰","叁","肆","伍","陆","柒","捌","玖");
  $dw = array("","拾","佰","仟","","萬","億","兆");
  $dec = "點";
  $retval = "";
  if($mode)
    preg_match_all("/^0*(\d*)\.?(\d*)/",$num, $ar);
  else
    preg_match_all("/(\d*)\.?(\d*)/",$num, $ar);
  if($ar[2][0] != "")
    $retval = $dec . ch_num($ar[2][0],false); //如果有小数,先递归处理小数
  if($ar[1][0] != "") {
    $str = strrev($ar[1][0]);
    for($i=0;$i      $out[$i] = $char[$str[$i]];
      if($mode) {
        $out[$i] .= $str[$i] != "0"? $dw[$i%4] : "";
        if($str[$i]+$str[$i-1] == 0)
          $out[$i] = "";
        if($i%4 == 0)
          $out[$i] .= $dw[4+floor($i/4)];
      }
    }
    $retval = join("",array_reverse($out)) . $retval;
  }
  return $retval;
}
//echo ch_num("12345006789001.123");
//echo ch_num("880079.1234");
echo ch_num("300045.0123");
?>

     
 

详细说明:http://php.662p.com/thread-364-1-1.html

Excel 2010怎把阿拉伯数字转成中文大写数字?(不要函数,有没有工具直接转换)

右键单元格,选择"设置单元格格式",
"数字"标签中左侧选择"特殊",右侧选择"中文大写数字"
 

在excel中 怎将中文表示的数字转换为阿拉伯数字??

没有此方面的直接方法,得看你的数据有什么样的规则,才能决定用什么函数帮忙。请举个例子,详细一些,如果不行,请传文件过来分析。
 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Tips for dynamically creating new functions in golang functions Tips for dynamically creating new functions in golang functions Apr 25, 2024 pm 02:39 PM

Go language provides two dynamic function creation technologies: closure and reflection. closures allow access to variables within the closure scope, and reflection can create new functions using the FuncOf function. These technologies are useful in customizing HTTP routers, implementing highly customizable systems, and building pluggable components.

Considerations for parameter order in C++ function naming Considerations for parameter order in C++ function naming Apr 24, 2024 pm 04:21 PM

In C++ function naming, it is crucial to consider parameter order to improve readability, reduce errors, and facilitate refactoring. Common parameter order conventions include: action-object, object-action, semantic meaning, and standard library compliance. The optimal order depends on the purpose of the function, parameter types, potential confusion, and language conventions.

How to write efficient and maintainable functions in Java? How to write efficient and maintainable functions in Java? Apr 24, 2024 am 11:33 AM

The key to writing efficient and maintainable Java functions is: keep it simple. Use meaningful naming. Handle special situations. Use appropriate visibility.

Complete collection of excel function formulas Complete collection of excel function formulas May 07, 2024 pm 12:04 PM

1. The SUM function is used to sum the numbers in a column or a group of cells, for example: =SUM(A1:J10). 2. The AVERAGE function is used to calculate the average of the numbers in a column or a group of cells, for example: =AVERAGE(A1:A10). 3. COUNT function, used to count the number of numbers or text in a column or a group of cells, for example: =COUNT(A1:A10) 4. IF function, used to make logical judgments based on specified conditions and return the corresponding result.

C++ Function Exception Advanced: Customized Error Handling C++ Function Exception Advanced: Customized Error Handling May 01, 2024 pm 06:39 PM

Exception handling in C++ can be enhanced through custom exception classes that provide specific error messages, contextual information, and perform custom actions based on the error type. Define an exception class inherited from std::exception to provide specific error information. Use the throw keyword to throw a custom exception. Use dynamic_cast in a try-catch block to convert the caught exception to a custom exception type. In the actual case, the open_file function throws a FileNotFoundException exception. Catching and handling the exception can provide a more specific error message.

Tsinghua Optics AI appears in Nature! Physical neural network, backpropagation is no longer needed Tsinghua Optics AI appears in Nature! Physical neural network, backpropagation is no longer needed Aug 10, 2024 pm 10:15 PM

Using light to train neural networks, Tsinghua University results were recently published in Nature! What should I do if I cannot apply the backpropagation algorithm? They proposed a Fully Forward Mode (FFM) training method that directly performs the training process in the physical optical system, overcoming the limitations of traditional digital computer simulations. To put it simply, it used to be necessary to model the physical system in detail and then simulate these models on a computer to train the network. The FFM method eliminates the modeling process and allows the system to directly use experimental data for learning and optimization. This also means that training no longer needs to check each layer from back to front (backpropagation), but can directly update the parameters of the network from front to back. To use an analogy, like a puzzle, backpropagation

Things to note when Golang functions receive map parameters Things to note when Golang functions receive map parameters Jun 04, 2024 am 10:31 AM

When passing a map to a function in Go, a copy will be created by default, and modifications to the copy will not affect the original map. If you need to modify the original map, you can pass it through a pointer. Empty maps need to be handled with care, because they are technically nil pointers, and passing an empty map to a function that expects a non-empty map will cause an error.

The magic formula for PHP function execution efficiency The magic formula for PHP function execution efficiency Apr 23, 2024 pm 10:21 PM

To solve the problem of low efficiency of PHP function execution, you can follow the following magic formula: reduce the number of parameters, use parameter passing by reference, shorten the length of the function body, and reduce the depth of function calls. Practical example: Passing parameters by reference can significantly improve performance. Best practices include: avoiding unnecessary calls, using caching, analyzing performance bottlenecks, and following coding standards.

See all articles