Round the number with number_format in PHP

Description

The following code shows how to round the number with number_format.

Example


// w w w .ja  v a2 s.co m
<?php
   $num = 1999.9;
   $formattedNum = number_format($num)."<br>";
    echo $formattedNum;
   $formattedNum = number_format($num, 2);
   echo $formattedNum;
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone