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
18 views
added Mar 27 in PHP by LC Marshal Lieutenant (13,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>

3 Responses

0 votes
responded Mar 29 by Callum Sergeant (1,480 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,480 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>
0 votes
responded Sep 18 by LC Marshal Lieutenant (13,770 points)
$out .= '<div class="row">
    <div class="col-sm-7 col-xs-7">
        <div class="p-card-info">
            <div class="names-align">RM '.number_format($re->amt, 0, '.', ',').' 


            </div>
            <div class="rm-type">'.date('M d, Y',strtotime($re->dat)).'</div>
        </div>
    </div>
    <div class="col-sm-5 col-xs-5">
        <div class="p-card-info info">
            <div class="names-align">'.ucfirst($re->st).' </div>
            <div class="rm-type-align">'.$re->code.'</div>
        </div>
    </div>
</div>
<div class="hr-market"></div>';

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...