Are you first timer at lazacode.org? Why not join us and start exchange your knowledge with everyone. Register today!

PHP number_format - Add comma and decimal

0 votes
2 views
added Mar 27 in PHP by LC Marshal Second Warrant Officer (6,690 points)
<div class="transaction-item transaction-price">
<?php
  $lot_size  = $row['area_sqft'];
  $psf  = $row['unit_price_psf'];
  $total_price = $lot_size * $psf; 
?>

<?php print number_format($total_price, 2, '.', ','); ?> 
</div>

2 examples

0 votes
responded Mar 29 by Callum Corporal (1,350 points)
<div class="transaction-item transaction-price">
<?php
$lot_size = $row['area_sqft'];
$psf      = $row['unit_price_psf'];

$total_price       = $lot_size * $psf;
$total_price_comma = number_format($total_price, 2, '.', ',');?>  
    <?php print str_replace(".0", "", $total_price_comma);?>
</div>
0 votes
responded Mar 29 by Callum Corporal (1,350 points)
<div>
<?php
  $lot_size = $row['area_sqft'];
  $psf      = $row['unit_price_psf'];

  $total_price       = $lot_size * $psf;
  $total_price_comma = number_format($total_price, 2, '.', ',');?>  
<?php print str_replace(".0", "", $total_price_comma);?>
   
</div>
lazacode.org - Malaysia based Knowledge Exchange Platform, where you can share your finding or solution with other members of community.
...