Skip to Main Content
PHP & MySQL®: Your visual blueprint™ for creating dynamic, database-driven Web sites
book

PHP & MySQL®: Your visual blueprint™ for creating dynamic, database-driven Web sites

by Janet Valade
September 2006
Intermediate to advanced content levelIntermediate to advanced
319 pages
9h 24m
English
Visual
Content preview from PHP & MySQL®: Your visual blueprint™ for creating dynamic, database-driven Web sites

Chapter 6. Some Useful PHP Built-In Functions

Format a Number

You can specify the number of decimal points that a number displays, a character to separate the number into thousands, and a character to separate the decimal places from the whole number with the number_format() function, as follows:

$f_number = number_format($number,
n_dec,"dec_char","thous_char");

You can use one, two, or four of the parameters, but not three. The default characters are a decimal point (.) to separate the decimal places and a comma (,) to separate the thousands, such as 1,234.56. If you specify only the first two parameters, the default characters are used.

If you specify a number of decimal places smaller than the number of decimal places in the number, number_format ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide

PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide

Larry Ullman

Publisher Resources

ISBN: 9780470048399Purchase book