johnrb87 Posted May 6, 2011 Share Posted May 6, 2011 hi I have the following value <?php $meters = '5.8654'; and I want to format this number into a format that looks like 5' 8" is this possible? thanks Link to comment https://forums.phpfreaks.com/topic/235736-format-number-into-feet-and-inches/ Share on other sites More sharing options...
xyph Posted May 6, 2011 Share Posted May 6, 2011 Yes, it IS possible I'm going to assume you want to know HOW it's done. <?php $metres = 5.25; $feet = floor( $metres / 0.3048 ); $inches = ($metres - 0.3048*$feet) / 0.0254; echo "$metres metres is $feet feet and ".round($inches,2)." inches"; ?> Quick n simple way. Based on 1 metre = 0.3048 feet, and 1 metre = 0.0254 inches. Link to comment https://forums.phpfreaks.com/topic/235736-format-number-into-feet-and-inches/#findComment-1211697 Share on other sites More sharing options...
johnrb87 Posted May 6, 2011 Author Share Posted May 6, 2011 cool thanks Link to comment https://forums.phpfreaks.com/topic/235736-format-number-into-feet-and-inches/#findComment-1211716 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.