Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- Apache
- Ajax
- HTML
- Regex
- 경영
- curl
- OOP
- Arrays
- 웹하드추천
- function
- 무료다운로드쿠폰
- post
- Session
- Laravel
- variables
- php
- date
- JSON
- Linux
- string
- 웹하드순위
- Forms
- composer-php
- jquery
- 전략
- UTF-8
- JavaScript
- MySQL
- file-upload
Archives
- Today
- Total
개발! 딱 깔끔하고 센스있게!
어떻게 PHP 를 10진수 를 단어로 전환합니까? 본문
나는 단지 약간의 도움이 필요할 뿐이다.
작은 숫자를 대문자로 바꾸는 화폐 형식으로 바꾸는 데 사용되기 때문이다.
하면, 만약, 만약...
이 번호가 있어요.
2143.45년
출력
"2,14,3,15분".
나는 이런 코드를 발견하였지만, 나는 어떻게 센트를 포함해야 할지 모르겠다.
0) { $output .= " point"; for ($i = 0; $i < strlen($fraction); $i++) { $output .= " " . convertDigit($fraction{$i}); } } return $output; } function convertGroup($index) { switch ($index) { case 11: return " decillion"; case 10: return " nonillion"; case 9: return " octillion"; case 8: return " septillion"; case 7: return " sextillion"; case 6: return " quintrillion"; case 5: return " quadrillion"; case 4: return " trillion"; case 3: return " billion"; case 2: return " million"; case 1: return " thousand"; case 0: return ""; } } function convertThreeDigit($digit1, $digit2, $digit3) { $buffer = ""; if ($digit1 == "0" && $digit2 == "0" && $digit3 == "0") { return ""; } if ($digit1 != "0") { $buffer .= convertDigit($digit1) . " hundred"; if ($digit2 != "0" || $digit3 != "0") { $buffer .= " and "; } } if ($digit2 != "0") { $buffer .= convertTwoDigit($digit2, $digit3); } else if ($digit3 != "0") { $buffer .= convertDigit($digit3); } return $buffer; } function convertTwoDigit($digit1, $digit2) { if ($digit2 == "0") { switch ($digit1) { case "1": return "ten"; case "2": return "twenty"; case "3": return "thirty"; case "4": return "forty"; case "5": return "fifty"; case "6": return "sixty"; case "7": return "seventy"; case "8": return "eighty"; case "9": return "ninety"; } } else if ($digit1 == "1") { switch ($digit2) { case "1": return "eleven"; case "2": return "twelve"; case "3": return "thirteen"; case "4": return "fourteen"; case "5": return "fifteen"; case "6": return "sixteen"; case "7": return "seventeen"; case "8": return "eighteen"; case "9": return "nineteen"; } } else { $temp = convertDigit($digit2); switch ($digit1) { case "2": return "twenty-$temp"; case "3": return "thirty-$temp"; case "4": return "forty-$temp"; case "5": return "fifty-$temp"; case "6": return "sixty-$temp"; case "7": return "seventy-$temp"; case "8": return "eighty-$temp"; case "9": return "ninety-$temp"; } } } function convertDigit($digit) { switch ($digit) { case "0": return "zero"; case "1": return "one"; case "2": return "two"; case "3": return "three"; case "4": return "four"; case "5": return "five"; case "6": return "six"; case "7": return "seven"; case "8": return "eight"; case "9": return "nine"; } } $num = 500254.89; $test = convertNumber($num); echo $test; ?>
대답
배 도서관이 이 점을 할 수 있다.
편집
아니면 코드의 끝부분에서 이렇게 할 수 있다
echo $test . ' cents';
'개발 스크랩 메모 > PHP' 카테고리의 다른 글
PHP 구조 함수와 정적 함수 (0) | 2020.12.28 |
---|---|
DIV 에서 포함된 PHP 파일을 자동으로 새로 고침 (0) | 2020.12.28 |
Apache 비기록 php 오류 (0) | 2020.12.28 |
PHP 로 jQuery 폼을 MYSQL 데이터베이스의$.ajax 요청 (0) | 2020.12.28 |
어떻게 php 을 통해 수정 날짜 에 따라 파일 을 정렬 하다 (0) | 2020.12.28 |
Comments