pdf generation - How to create pdf using array values in php



Hello everybody i am new fpdf. I have multiple array values and create a table.

$array2=['apple', "ball", "cat"];

I want to create a table using this values

Numbers Animals
1       Apple
2       Ball
3       Cat

I have tried this way but all values are printing one by one

$pdf = new FPDF();

for ($i=0; $i < count($array1); $i++) { 
    [$pdf->MultiCell(30,12,$array1[$i],1), $pdf->MultiCell(30,12,$array2[$i],1)];

Can anyone suggestion me how this problem. Thanks in advance.

1 Answer: 

$pdf = new FPDF();

$array1= array(1,2,3);
$array2= array('apple', "ball", "cat");

foreach($array1 as $key=>$row){

As FPDF examples you can uses Cell() for display values. And For the Line breaks use Ln(). I assume both $array1 and array2 have similar number of elements. First two Cells use to display headings, then inside the loop display both values.