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

PHP number_format - Add comma and decimal

0 votes
3 views
added Mar 27 in PHP by LC Marshal First Warrant Officer (11,770 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 Responses

0 votes
responded Mar 29 by Callum Sergeant (1,450 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 Sergeant (1,450 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's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...