Search code examples
phpfpdf

FPDF setting 2 consecutive values in one cell


I just need to find out how to set 2 values from MySQL database in a FPDF. The values will be consecutive with a 'dash' in between them. Here is an example of what I want to do.

$pdf->Cell(110, 7,$address1 ' - ', $address2);

Solution

  • You are using a comma but should be using the dot '.'. FPF is seeing these as different arguments separated by commas.

    // this will work (note the dots instead of the comma)
    $pdf->Cell(110, 7,$address1 . ' - ' . $address2);
    
    // I prefer this: it is easier to read
    $fullAddress = $address1 . ' - ' . $address2;
    $pdf->Cell(110, 7,$fullAddress);