Table of Contents

Syntax

string number_format(float $number [, int $decimals = 0])
string number_format(float $number , int $decimals = 0, string $decimal_point = '.', string $thousands_sep = ',')

(PHP 4, PHP 5)

$number The number we want to format.
$decimals The number of decimals shown after the decimal point.
$decimal_point The character string to use in place of the decimal point.
$thousands_sep The character string to use in place of the thousands separator.
RETURNS The number formatted according to the paramters.

What it Does

Formats a number according to the parameters given. The parameters allow you to define how many digits are shown after the decimal point ($decimals). You may also define the string to use for the $decimal_point and the $thousands_sep.

Example

// format a number using number_format
$formatted = number_format(1023.47, 2, '&mdot;', ',');
echo 'Formatted Number: '.$formatted;
 
number_format.txt · Last modified: 2011/02/16 13:03 by orvado
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki