当前位置:网站首页>Capital digit to number format
Capital digit to number format
2022-06-13 03:04:00 【good_ boys】
- Such as : one hundred and thirty-five Turn into 135
function chinese2number($chNum) {
$numArr = array(
' zero ' => '0',
' One ' => '1',
' Two ' => '2',
' 3、 ... and ' => '3',
' Four ' => '4',
' 5、 ... and ' => '5',
' 6、 ... and ' => '6',
' 7、 ... and ' => '7',
' 8、 ... and ' => '8',
' Nine ' => '9',
);
$numUnit = array(
' Ten ' =>'10',
' hundred ' =>'100',
' thousand ' =>'1000',
' ten thousand ' =>'10000',
' Billion ' =>'100000000',
);
$number = 0;
for ($i = 0;$i<=mb_strlen($chNum); $i++) {
$str = mb_substr($chNum,$i,2);
$first = mb_substr($str,0,1);
$second = mb_substr($str,1,1);
if (isset($numUnit[$first])){
if (!$number) {
$number = 1;
}
$number *= $numUnit[$first];
} else if (isset($numArr[$first])) {
$i++;
if (isset($numArr[$second])) {
if ($numArr[$first] == 0) {
$i--;
}else{
$number += intval($numArr[$first].$numArr[$second]);
}
} else if(isset($numUnit[$second])) {
$number += intval($numArr[$first]*$numUnit[$second]);
} else{
$number += intval($numArr[$first]);
}
}
}
return $number;
}
边栏推荐
- vant实现移动端的适配
- Introduction to facial expression recognition system - Technical Paper Edition
- [data analysis and visualization] key points of data drawing 8- use of circular bar chart
- [common tools] pyautogui tutorial
- Typical application of ACL
- Detailed installation tutorial of MATLAB r2019 B-mode ultrasound (complete installation files are attached)
- IOS development interview knowledge sorting - OC Foundation (II)
- Ijkplayer source code - remuxing
- Traverse the array and delete an element until it is deleted
- Node uses post to request req Pit with empty body
猜你喜欢

Applet image component long press to identify supported codes

MySQL index bottom layer (I)

Linked list: orderly circular linked list

When the flutter runs the project, the gradle download fails, and the running gradle task 'assemblydebug' is always displayed

Summary of the latest IOS interview questions in June 2020 (answers)

Available types in C #_ Unavailable type_ C double question mark_ C question mark point_ C null is not equal to

Mp4 playback

Introduction to facial expression recognition system - Technical Paper Edition

Spark UDF instance details

Introduction to facial expression recognition system -- offline environment configuration
随机推荐
IOS development interview knowledge sorting - OC Foundation (II)
Mvcc and bufferpool (VI)
IOS development internal volume interview questions
Explain tool and index optimization (II)
JVM JMM (VI)
[data analysis and visualization] key points of data drawing 11- precautions for radar chart
Ijkplayer source code - setting option 2
PK of dotnet architecture
mysql索引
Scala implements workcount
How to select fund products? What kind of fund is a good fund?
Image classification system based on support vector machine (Matlab GUI interface version)
The latest Matlab r2020 B ultrasonic detailed installation tutorial (with complete installation files)
Pytorch record: pytorch variables parameter and buffer. self. register_ buffer()、self. register_ parameter()
Flutter reports an error type 'Int' is not a subtype of type 'string' wonderful experience
Vscode liveserver use_ Liveserver startup debugging
Linked list: adding numbers in the linked list
Linked list: the first coincident node of two linked lists
OneNote User Guide (1)
Review notes of RS data communication foundation STP