duanhuren5581 2014-12-15 09:35
浏览 13

当价格超过500时,价格/ 1000 * 38不显示

Below is the code I have, it should take the price of a product then divide by 1000 then times by 38 to get and print the lease_price for products over £500. However, all it does it print NA, even when the product is over £500 it still shows NA. I don't know what is wrong with this? As far as I know this should work.

<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>
  • 写回答

1条回答 默认 最新

  • dongmu6225 2014-12-17 14:32
    关注
    <?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';
      }
     ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥15 Python3.5 相关代码写作
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗