컴

number_format - 그룹화 된 수천의 숫자 서식 지정

· 2017-03-16 (목) 23:31:36 · 2425

number_format - 그룹화 된 수천의 숫자 서식 지정

 

설명 ¶

 

string number_format ( float $number [, int $decimals= 0 ])

string number_format ( float $number , int $decimals= 0 , string $dec_point= "." , string $thousands_sep= "," )

이 함수는 한 개, 두 개 또는 네 개의 매개 변수를 받아들입니다 (세 개가 아님).

 

하나의 매개 변수 만 주어지면 number십진수는 없지만 쉼표 ( ",")는 각 그룹 사이에 지정됩니다.

 

두 개의 매개 변수가 주어 number지면 앞뒤에 decimals점 ( ".") 이 있고 소수점으로 쉼표 ( ",")가있는 십진수로 형식이 지정됩니다.

 

네 개의 매개 변수를 제공하는 경우 number 로 포맷됩니다 decimals, 소수 dec_point대신 소수 전에 점 ( ".")과 thousands_sep수천의 모든 그룹 사이에 ( ",") 대신 쉼표의.

 

매개 변수 ¶

 

number

형식이 지정되는 숫자입니다.

 

decimals

소수점의 수를 설정합니다.

 

dec_point

소수점의 단락 기호를 설정합니다.

 

thousands_sep

천 단위 구분 기호를 설정합니다.

 

반환 값 ¶

 

의 포맷 버전 number.

 

예 ¶

 

Example # 1 number_format () 예제

 

예를 들어, 프랑스 표기법은 대개 소수 자릿수로 쉼표 ( ',')를 사용하고 천 단위 구분 기호로 공백 ( '')을 사용합니다. 다음 예제에서는 숫자 서식을 지정하는 다양한 방법을 보여줍니다.

 

<?php

 

$number = 1234.56;

 

// english notation (default)

$english_format_number = number_format($number);

// 1,235

 

// French notation

$nombre_format_francais = number_format($number, 2, ',', ' ');

// 1 234,56

 

$number = 1234.5678;

 

// english notation without thousands separator

$english_format_number = number_format($number, 2, '.', '');

// 1234.57

 

?>

|
댓글을 작성하시려면 로그인이 필요합니다.

개발자팁

5,403건

개발과 관련된 유용한 정보를 공유하세요. 질문은 QA에서 해주시기 바랍니다.

+
분류 제목 글쓴이 날짜 조회
jQuery 17-03-18 조회 2,826
jQuery 17-03-18 조회 2,409
PHP 17-03-18 조회 4,443
jQuery 17-03-17 조회 2,268
jQuery 17-03-17 조회 2,311
jQuery 17-03-17 조회 2,174
jQuery 17-03-17 조회 3,166
PHP 17-03-16 조회 2,426
PHP 17-03-16 조회 2,255
PHP 17-03-16 조회 2,463
기타 17-03-16 조회 1.6만
OS 17-03-16 조회 3,542
jQuery 17-03-15 조회 2,599
jQuery 17-03-15 조회 2,667
jQuery 17-03-15 조회 2,770
jQuery 17-03-14 조회 2,565
jQuery 17-03-14 조회 2,697
jQuery 17-03-14 조회 3,649
PHP 17-03-13 조회 2,607
PHP 17-03-13 조회 2,401
PHP 17-03-13 조회 2,669
PHP 17-03-11 조회 2,391
PHP 17-03-11 조회 3,080
PHP 17-03-11 조회 2,742
jQuery 17-03-11 조회 2,752
jQuery 17-03-11 조회 2,844
jQuery 17-03-11 조회 2,266
jQuery 17-03-10 조회 2,279
jQuery 17-03-10 조회 2,267
jQuery 17-03-10 조회 2,651