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

PHP 利用phpmailer 寄信...

PHP 利用phpmaile...

一般來說其實PHP本身已經提供了Mail()函數可以使用,但由於一些令人不愉快的原因...我租用的V...

瀏覽器升級ie9後FCKEditor無法使用對話框解決方法

瀏覽器升級ie9後FCKEd...

原文網址:http://ecshop.tw/bbs/archiver/tid.html 升級到 IE...

CSS3 box-shadow

CSS3 box-shado...

便利貼~俗稱小黃(對我來說),依據wiki的說法~是M公司的工程師史賓塞·席佛經過5年後出現成果。 ...

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