• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

to digit decimal php

$vat = $Grandtotal / 0.07 ;

How can I make $vat become 2 didgit decimal
0
teera
Asked:
teera
  • 2
4 Solutions
 
psychic_zeroCommented:
0
 
psychic_zeroCommented:
You mean 2 decimal points? Try this

 $vat = sprintf("%01.2f",  $vat);
0
 
hernst42Commented:
echo number_format($vat, 2);

http://www.php.net/number_format
0
 
lexxwernCommented:
You can set the precision at run time:

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

- lexxwern
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now