Jump to content

[SOLVED] remove trailings 00


AnotherQuestion

Recommended Posts

Yes, number_format() is what you want.

 

$original = 12.3456789;
$two_decimal = number_format($original, 2);
//Output: 12.35

 

It will also have the effect of increasing the value to two decimals if less than two. In addition, it will round the value to two decimals if needed.

thanks bundyxc your method worked.

 

final code used was

<?php $InvTotal = $row_RSInvoiceHeader['Invoice_Total'];
$point = strpos($InvTotal, '.');
$InvTotalSum = substr($InvTotal, 0, $point + 3); ?>
          <?php echo $InvTotalSum; ?>

 

 

Ok, you do realize that there is a built-in function within PHP to do exactly what you asked for which Mark Baker first suggested, right? But instead you decide to build a customer function for something PHP already does. Brilliant!  :facepalm:

 

You could replce those four lines of code with just this

echo number_format($row_RSInvoiceHeader['Invoice_Total'], 2);

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.