일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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
- JPA
- 디자인패턴
- nginx
- kafka
- 웹사이트성능
- GCM 번역
- 페이스북 번역
- 푸시 번역
- nginx설정
- 카프카
- 자바스크립트
- 푸시
- APNS
- git
- Java
- notification
- 성능
- Push
- ddd
- 웹사이트최적화기법
- nginx설치
- 도메인 주도 개발
- 카프카 트랜잭션
- gcm 푸시 번역
- GCM
- php
- 웹사이트 성능
- graphql
- Design Pattern
Archives
- Today
- Total
간단한 개발관련 내용
php number_format() 본문
반응형
money_format() 을 쓰려다가 number_format() 있길래 사용함.
number_format
(PHP 4, PHP 5)
number_format — 천의 단위로 숫자를 포맷팅한다.
Description ¶
string number_format ( float
$number
[, int $decimals
= 0 ] )string number_format ( float
$number
, int $decimals
= 0 , string $dec_point
= '.' , string $thousands_sep
= ',' )이 함수는 1개나 2개 또는 4개의 파라미터만 사용한다.(3개 안됨):
한 파라미터만 주어진다면, number
(첫번째 param) decimals(2번째 param) 없이 포맷팅 될 것임, 여튼 천 단위별로 콤마(,)가 찍힐거다.
두 개의 파라미터가 주어진다면, number
는 decimals
dot (".") 으로 구분되는 소숫점을 가진, 천의 단위로 콤마를 가질 것이다.
4개의 파라미터가 주어진다면, number
will be formatted with decimals
decimals, dec_point
instead of a dot (".") before the decimals andthousands_sep
instead of a comma (",") between every group of thousands.
Parameters ¶
number
The number being formatted.
decimals
Sets the number of decimal points.
dec_point
Sets the separator for the decimal point.
thousands_sep
Sets the thousands separator.
그래서 ... 확인해보니 number_format($number, '0', '.', ','); 랑 number($number) 가 기본 숫자 사용 시에는 같은 결과를 나타냈다.
반응형