CONVERT TWO DIGIT DECIMAL POINTS IN PHP
Hi friends & Students
In this post we see, how to convert two digit decimal points in PHP detailed
Ex:
20.0 = 20.00
1450.5 = 1450.00
PHP CODE
$variable="20.5"; // 20.50
$variable="1450.5"; //1450.50
Like this kind of needs, Use number_format() methods, very easy varibalename,number of digits.
Ex:
number_format($variable, 2);
PHP EXAMPLE CODE :
<?php
$price="20.5";
$res=number_format($price, 2);
echo "Rs.".$res;
?>
OUTPUT
Rs.20.50
No comments:
Post a Comment