如何在PHP FPDF中显示十进制值?

This is my code :

$no=1;
while($item = mysqli_fetch_array($query)){
    $pdf->Cell(10   ,5,$no++,1,0);
    $pdf->Cell(100  ,5,$item['naran'],1,0);
    //add thousand separator using number_format function
    $pdf->Cell(25   ,5,number_format ( $item['folin_faan']),1,0);
    $pdf->Cell(25   ,5,number_format( $item['hamutuk']),1,0);
    $pdf->Cell(34   ,5,number_format( $item['total']),1,1,'R');//end of line
    //accumulate tax and amount
    $tax += $item['hamutuk'];
    $total += $item['total'];

}

It is supposed to display decimal value like 0.00

The column I want display decimal value:

enter image description here

Question : how exactly function to display decimal value?

Your number_format() parameters seem off if you desire 0.00 and similar.

Try this:

number_format($item['total'], 2, '.', '');

This shows 2 decimals using . as decimal point and having (nothing) as thousands separator.


Full code:

$no=1;
while($item = mysqli_fetch_array($query)){
    $pdf->Cell(10, 5, $no++, 1, 0);
    $pdf->Cell(100, 5, $item['naran'], 1, 0);
    // add thousand separator using number_format function
    $pdf->Cell(25, 5, number_format($item['folin_faan'], 2, '.', ''), 1, 0);
    $pdf->Cell(25, 5, number_format($item['hamutuk'], 2, '.', ''), 1, 0);
    $pdf->Cell(34, 5, number_format($item['total'], 2, '.', ''), 1, 1, 'R'); // end of line
    // accumulate tax and amount
    $tax += $item['hamutuk'];
    $total += $item['total'];
}