doushang4274 2015-06-29 08:41
浏览 24
已采纳

FPDF中PHP的百分比计算

I am looking to make a percentage calculation on an FPDF based invoice template which contains $total (e.g 1000) and a number value $percentage (e.g. 20)

Ideally I would like this to display as discount

$pdf->Cell(100, 5, 'Discount' .$discountresult. '', 0, 'L');

How to achieve this? Some advice would be appreciated.

  • 写回答

1条回答 默认 最新

  • dongpai6552 2015-06-29 08:56
    关注

    Like this:

    $total = 1000;
    $percentage = 20;
    
    $discountResult =  $total - (($percentage / 100) * $total);
    
    $pdf->Cell(100, 5, 'Discount' . $discountResult, 0, 'L');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?