PHP - number_format 函式



語法

inputber_format(inputber,decimals,decimalpoint,separator)

定義和用法

它用於格式化數字,並以千位分隔符分組。

返回值

它返回格式化的數字。

引數

序號 引數及描述
1

number

包含要格式化的數字資訊。

2

decimals

指定要設定的小數位數。

3

decimalpoint

指定用於小數點的字串。

4

separator

指定用於分隔千位字串的字串。

示例

嘗試以下示例

<?php
   $input = 100.9;
   $formattedinput = inputber_format($input)."<br>";
   echo $formattedinput;
   
   $formattedinput = inputber_format($input, 2);
   echo $formattedinput;
?>

這將產生以下結果 -

101
100.90
php_function_reference.htm
廣告