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

Google map 語言本地化

Google map 語言本...

網路世界的強大...真的是解決問題的好幫手.....雖說有些答案並不可靠.... 但原則上...只要...

HTML5 影音手持裝置適應不良篇

HTML5 影音手持裝置適應...

這天下午跟客戶開完會... 客戶針對專案中手持裝置網站適應性做了需調整的說明..另外還包括影音檔播放...

CSS Radio Button

CSS Radio Butt...

寫系統的時候三不五時總會用到Radio Button 和 Checkboxes 目前就在寫這個部份@...

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