Solved

to digit decimal php

Posted on 2008-06-19
4
230 Views
Last Modified: 2012-06-27
$vat = $Grandtotal / 0.07 ;

How can I make $vat become 2 didgit decimal
0
Comment
Question by:teera
  • 2
4 Comments
 
LVL 6

Accepted Solution

by:
psychic_zero earned 200 total points
ID: 21820602
0
 
LVL 6

Assisted Solution

by:psychic_zero
psychic_zero earned 200 total points
ID: 21820616
You mean 2 decimal points? Try this

 $vat = sprintf("%01.2f",  $vat);
0
 
LVL 48

Assisted Solution

by:hernst42
hernst42 earned 75 total points
ID: 21820617
echo number_format($vat, 2);

http://www.php.net/number_format
0
 
LVL 12

Assisted Solution

by:lexxwern
lexxwern earned 75 total points
ID: 21820673
You can set the precision at run time:

<?php
 ini_set('precision',2);
?>

- lexxwern
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now