Thursday, November 01, 2012

PHP Display floating number with 2 leading zeros


<?php
 $no = "2.8" ;

$no1 =  sprintf("%01.2f",$no);

echo $no1;
echo "<br/>";

?>

output : 2.80

// suppose input is 0.4 => output 0.40

No comments:

Post a Comment