PHP + Math Logic [Easy]

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
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

PHP + Math Logic [Easy]

Post by tecktalkcm0391 »

My brain is dead right now :? ... How can I figure out how many pounds and ounces are in x knowing 1 pound = 16 ounces. I want php to convert say 234 ounces to whatever pounds and y ounces.

Thanks:!:
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Your either way tired or you smoke tooooo much weed.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Code: Select all

$pounds = floor($ounces / 16);
$ounces = $ounces - ($pounds * 16);
I'm tired too, but that should work.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

astions wrote:Your either way tired or you smoke tooooo much weed.
It's definitely the way tired.
User avatar
tecktalkcm0391
DevNet Resident
Posts: 1030
Joined: Fri May 26, 2006 9:25 am
Location: Florida

Post by tecktalkcm0391 »

astions wrote:

Code: Select all

$pounds = floor($ounces / 16);
$ounces = $ounces - ($pounds * 16);
I'm tired too, but that should work.
Thanks! Worked.
Now I'm off to bed. :wink:
Post Reply