Page 1 of 1

cutting off a decimal number

Posted: Wed Dec 25, 2002 12:31 pm
by megaming
Ok, so if I had $val that was say 3.12738437483793

How would I cut that off so that $val = 3.127 ?

Thanks maties :D

Posted: Wed Dec 25, 2002 2:43 pm
by mydimension

Posted: Wed Dec 25, 2002 3:09 pm
by hob_goblin

Posted: Wed Dec 25, 2002 3:12 pm
by megaming
Could you write up the code for me please... i really can't read from the manual very well :(

Thanks again!

Posted: Wed Dec 25, 2002 10:25 pm
by evilcoder

Code: Select all

<?php

$var = "3.12738437483793";
echo round($var, 3)

?>