to digit decimal php

$vat = $Grandtotal / 0.07 ;

How can I make $vat become 2 didgit decimal
teeraAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
psychic_zeroConnect With a Mentor Commented:
0
 
psychic_zeroConnect With a Mentor Commented:
You mean 2 decimal points? Try this

 $vat = sprintf("%01.2f",  $vat);
0
 
hernst42Connect With a Mentor Commented:
echo number_format($vat, 2);

http://www.php.net/number_format
0
 
lexxwernConnect With a Mentor Commented:
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.

All Courses

From novice to tech pro — start learning today.