In PHP & javascript
I need to get float after point values only. How to get that.
E.g 1618867.7142857143
to 0.7
or 7
like this
Asked
Active
Viewed 46 times
-3

dinesh balan
- 318
- 1
- 14
-
2[How much research effort is expected of Stack Overflow users?](https://meta.stackoverflow.com/a/261593/3082296) – adiga Dec 26 '22 at 07:08
1 Answers
0
$number = 1618867.7142857143;
$decimal = $number % 1;
echo $decimal; // Outputs 0.7142857143

Nuhman Pk
- 112
- 7
-
if I need only first number of after point how to get that like o.7 only – dinesh balan Dec 26 '22 at 07:07
-
$number = 1618867.7142857143; $decimal = $number % 1; $digit = round($decimal, 1); echo $digit; // Outputs 0.7 – Nuhman Pk Dec 26 '22 at 07:16
-