Last active
August 29, 2015 14:05
-
-
Save graceman9/2f912b28e6c8aecf4421 to your computer and use it in GitHub Desktop.
PHP: get whole and fraction parts of decimal value
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* See: | |
* http://stackoverflow.com/questions/6619377/how-to-get-whole-and-decimal-part-of-a-number | |
*/ | |
// get whole and fraction parts of decimal value | |
$amount = 1.25; | |
$whole = floor($amount); // 1 | |
$fraction = $amount - $whole; // .25 | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment