PHP使用数字[复制]

This question already has an answer here:

I have two values coming from the database that are for payments, these numbers need to be rounded to the correct format, the way I'm doing it is not working.

Number1: 150000 -> This should be £150.00
Number1: 3000 -> This should be £30.00

Using

<?="£" . number_format($packagePrice,2);?>

Returns

Total Price: £18,000.00 
It should be £180.00

Thanks

</div>

PHP does it right as you past it an integer and number_format just adds following zeroes.

A quick solution would be to divide by 100 or 1000 depending on how you save to DB

<?="£" . number_format($packagePrice/100,2);?>

Try this :

$number = 150000;

// Default english notation
$english_format_number = "£".number_format($number);
print($english_format_number);