cutting off a decimal number

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
megaming
Forum Commoner
Posts: 27
Joined: Wed Dec 25, 2002 12:31 pm

cutting off a decimal number

Post 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
User avatar
mydimension
Moderator
Posts: 531
Joined: Tue Apr 23, 2002 6:00 pm
Location: Lowell, MA USA
Contact:

Post by mydimension »

User avatar
hob_goblin
Forum Regular
Posts: 978
Joined: Sun Apr 28, 2002 9:53 pm
Contact:

Post by hob_goblin »

megaming
Forum Commoner
Posts: 27
Joined: Wed Dec 25, 2002 12:31 pm

Post by megaming »

Could you write up the code for me please... i really can't read from the manual very well :(

Thanks again!
evilcoder
Forum Contributor
Posts: 345
Joined: Tue Dec 17, 2002 5:37 am
Location: Sydney, Australia

Post by evilcoder »

Code: Select all

<?php

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

?>
Post Reply