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

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

瀏覽器升級ie9後FCKEd...

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

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

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

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

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

Android Studio...

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

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