Function that returns shorter 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
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Function that returns shorter number?

Post by IAD »

Hey,

i can't remmeber the functiopn that make numbers shorter, for example: 0.55453212 will be 0.55


Happy new year, Tal.
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

Round is capable for what your asking.
IAD
Forum Commoner
Posts: 42
Joined: Wed Dec 28, 2005 12:36 pm
Location: Israel, Soon Canada :)

Post by IAD »

Not exactly, round makes number like 1.9 to 2, what i wanted is to turn number like: 0.45812 to 0.458, and then i got remember at "substr();"

Code: Select all

<?Php
  $num = "1.3334";

        print substr($num,0,5); // will return 1.333
?>

Tal
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post by mickd »

ah, so you dont want the numbers to be rounded up/down. my mistake.
Post Reply