以下是我的代码,它应该将产品的价格除以1000然后除以38以获得并打印超过500英镑的产品的lease_price。然而,所有它都打印NA,即使产品超过500英镑它仍然显示NA。我不知道这有什么问题?据我所知,这应该有用。
<p> <i class="fa fa-chevron-down"></i> <b>Lease To Buy Price:</b>
<span>
<?php
$tempPrice = str_replace(',',"", $price); //gets rid of ","
$tempPrice = substr($tempPrice,1); //removes currency from the front
$tempPrice = floatval($tempPrice); //converts to double from string
if($special > 0)
{
$lease_price = (($special/1000)*38);
}
else
{
$lease_price = (($tempPrice/1000)*38);
}
$lease_price = $this->currency->format($lease_price);
if($tempPrice > 500)
{
echo $lease_price;
}
else
{
echo 'NA';
}
?>
</span></p>
答案 0 :(得分: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 > 500)
{
echo $tempPrice*0.038;
}
else
{
echo 'NA';
}
?>