Wednesday, 6 July 2022

Easy convert two digit decimal points in PHP with Source Code

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

What is AI- Artificial Intelligence - தமிழில்

Artificial Intelligence : Artificial intelligence leverages computers and machines to mimic the problem-solving and decision-making capabili...