Solved

to digit decimal php

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

932 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