Reputation: 83
My variable is: $No = '9.80000000000'
I want a result like this: $No = '9.80'
I tried to use the round function with 2 decimal points, but I get results like this: $No = '9.8'
I want to have a specific numeric scale precision.
My expected result is: $No = '9.80'
.
Upvotes: 2
Views: 2967
Reputation: 324
round()
function omits last digit zero so better use the number_format() function.
eg:
round($No,2) //your code.
change this function to like below
eg:
number_format($No, 2);
I hope it will help you.
Upvotes: 7
Reputation: 541
the digit 0 has no value after decimal point. you can use this :
echo substr('9.80000000000', 0,4);
Upvotes: 0