Skip to content

Instantly share code, notes, and snippets.

@graceman9
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save graceman9/2f912b28e6c8aecf4421 to your computer and use it in GitHub Desktop.
Save graceman9/2f912b28e6c8aecf4421 to your computer and use it in GitHub Desktop.
PHP: get whole and fraction parts of decimal value
<?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