How would you find the fractional part of a floating point number in PHP?
For example, if I have the value 1.25, I want to return 0.25.
1.25
0.25
Some of the preceding answers are partial. This, I believe, is what you need to handle all situations:
function getDecimalPart($floatNum) { return abs($floatNum - intval($floatNum)); } $decimalPart = getDecimalPart($floatNum);