Solved

to digit decimal php

Posted on 2008-06-19
4
233 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
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…

813 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

10 Experts available now in Live!

Get 1:1 Help Now