Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

format value

Status
Not open for further replies.

Brianfree

Programmer
Feb 6, 2008
220
GB
Hi, i have some php values like...

7.5000
11.5000
25



How can i display them like...

7.50
11.50
25.00

Many thanks,

BF
 
Hi thanks for replying, is there a way to do this in a function like...

format(value,'.00')

or something? The values are from a recordset..

Many thanks,

BF
 
Hi

Oops. Sorry. I have no idea why I had the feeling the you asked in the Unix scripting forum.

However the [tt]printf()[/tt] function of C is implemented/replicated in many languages. Including PHP.

I think you probably want its variant, the [tt]sprintf()[/tt] function.
PHP:
$formatted = sprintf( '%.2f', $value );


Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top