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

利用 css 讓 ul 置中呈現

利用 css 讓 ul 置中...

以前寫網站...總是喜歡用Table 包住內容.. 而隨著時空的轉換...現在大都用div..或者....

PHP 時間時區修正

PHP 時間時區修正

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

讓圖片上傳前先產生預覽

讓圖片上傳前先產生預覽

專案需要,上傳圖片至網站時先產生預覽圖~ 參考了stackoverflow.com裡討論的的方式

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