Sorry I couldn't explain clearly in the title. I Studied math in other language I don't know what it calls.
I have these values.
$input = 13.2156;
$input = 45.232;
$input = 1193.215624;
I want a function in PHP to get what what after the dot, which is this case
$input = 13.2156; // 0.2156
$input = 45.232; // 0.232
$input = 1193.215624; // 0.215624
I know intval()
do the opposite. BUT I want the opposite of the opposite. :D
$input = $input - intval($input);
For negative numbers, the above code will get a negative decimal component (which may be desired in some cases). If you always want the positive decimal component, just take the absolute value of $input
.
Try $input = $input - intval($input).
This leaves just the fraction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With