How to remove decimals in php (sql)?

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
Darla
Forum Newbie
Posts: 16
Joined: Mon Feb 12, 2007 8:27 am

How to remove decimals in php (sql)?

Post by Darla »

Hello

I am wondering if there are any ways to remove extra decimals in php (or alternatively in sql)? I fetch aome average values from a table, and I wish to keep only one decimal or remove decimals entirely.
Ex:
14.6154 should be 14.6 og just 14.

Are there any "ready-to-use" functions for this in php/mysql?

Darla
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

uh, round() and uh.. ROUND()
Darla
Forum Newbie
Posts: 16
Joined: Mon Feb 12, 2007 8:27 am

Post by Darla »

Thanks, cant believe I did not find this when searhing php.net... I must be tired.
Well, it works perfectly now :)
Post Reply