?
Solved

to digit decimal php

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

How can I make $vat become 2 didgit decimal
0
Comment
Question by:teera
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 6

Accepted Solution

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

Assisted Solution

by:psychic_zero
psychic_zero earned 800 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 300 total points
ID: 21820617
echo number_format($vat, 2);

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

Assisted Solution

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

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

- lexxwern
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses how to implement server side field validation and display customized error messages to the client.
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 count occurrences of each item in an array.
Suggested Courses

764 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