- var_dump: documentation ( source)
- round: documentation ( source)
- number_format: documentation ( source)
- sprintf: documentation ( source)
- printf: documentation ( source)
<?php
$rate1 = 0.02;
$var = sprintf("%.2f",1260); //$var holds numeric string
var_dump($var,"\n\n");
$var = 1260;
$product = $var * $rate1;
var_dump("product:", $product,"\n");
// two ways to format $product
echo number_format( $product, 2),"\n";
echo printf("%f",round($product,2));