PHP:Formatting

From Progzoo
Jump to: navigation, search

You can format numbers using the sprintf function. See PHP:Format Printing for details of some other options that are available.

You can build a string using sprintf. The %8d place holder will ensure that the number takes exactly 8 spaces.

The output with "Number:%8d" prints a decimal in 8 spaces:

Number:   12345


[Font] [Default] [Show] [Resize] [History] [Profile]