我需要使這個打印數字有兩個小數點,我相信我使用這段代碼int $decimals = 0
,但我不知道我需要添加它的位置。
這裏是我的代碼:
<?php
$tempPrice = str_replace(',',"", $price); //gets rid of ","
$tempPrice = substr($tempPrice,2); //removes currency from the front
$tempPrice = floatval($tempPrice); //converts to double from string
if($tempPrice > 1000)
{
echo '£' . round(($tempPrice*0.038), 2) . ' per month';
}
else
{
echo 'Lease to buy price not available on this product';
}
?>
感謝
'number_format' – 2015-03-31 09:36:01