Loading...

PHP數字1000分位逗號分隔函數number_format()

Temperature: 0 °C

ChungChung
author_tools

有時候們必需將數字加上每三個位數加上一個逗號(千分位),例如18000變成18,000,雖不常用...但偶爾要用到時又會忘記...。


$number = 1234.56;
# 英文表示法(默認)
$english_format_number = number_format($number);
# 1,235
# 法語表示法
$nombre_format_francais = number_format($number, 2, ',', ' ');
# 1 234,56
$number = 1234.5678;
# 英文表示法,不帶千分位
$english_format_number = number_format($number, 2, '.', '');
# 1234.57
#中文最常用的表示法,千分位為',',浮點分割為'.',保留兩位浮點數
$chinese_format_number = number_format($number,2,'.',',');
#1,234.57

#php  #numberformat  #千分位  #保留兩位浮點數  
https://innstory.com/story-PHP數字1000分位逗號分隔函數numberformat-225
寫程式筆記

Prev
 PHP_時間時區修正

Next
逸歡旅遊 

About the Author

Chung

我是chung
網路工作者
主業是網站系統開發建置
副業是做夢,寫故事
作品請參考/teme.biz
做夢請參考/innstory.com
聯絡/chung.teme@gmail.com

#有人用筆寫日記,有人用歲月寫日記,有人用照片寫日記,而我,用innstory寫日記。

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

Android Studio 2.3 陽春型計算機進階版

Android Studio...

andrio5 將之前的陽春型計算機用了不怎麼聰明的方式改善了幾個地方。 首先,我將數字的宣告由in...

PHP 時間時區修正

PHP 時間時區修正

一般來說...PHP取得的時間,是格林威治的時間: 但如果要將時間調成臺灣的時區,或其他時區的話,必...

行事曆功能導入

行事曆功能導入

cc55 Innstory有行事曆囉! 我試著把Innstory當作是我的筆記本,將生活發生的故事紀...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format