PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1847
Number of posts: 5013

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Add code for decimal places Posted by newphpcoder on 21 Nov 2010 at 6:59 PM
Good day!

I want to know where I can put this code :
[PHP]
number_format($num), 2;
[/php]

I have this code:
[PHP]
echo mysql_result ($result,$ctr,"inputqty");
[/php]

I want the output if this code is in 2 decimal places for example the output in this code is: 1.9856211 I want to become is like this 1.99

I hope somebody can help me...thank you..
Report
Re: Add code for decimal places Posted by stephen_sween on 3 Feb 2011 at 6:07 PM
Hi your almost there!

number_format($num,'2','.'.'');

This will print out the result you want!

Stephen



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.