I’m trying to loop through an JSON array in PHP and fill a fpdf table
My constructed string is valid JSON and looks like this:
[
{"ap":"j4","la":"02.02.2012","tr":"30 Tage","tra":"19.95EUR"},
{"ap":"de","la":"27.09.2012","tr":"30 Tage","tra":"19.95EUR"},
...
]
Which I’m setting as
if($rvar_apps != ""){
$activeAppsJson = json_decode( $rvar_apps ,true);
}
And then I’m trying this, which blanks the page:
if( $activeAppsJson ){
for($activeAppsJson as $item) {
$pdf->Cell(25,8,$item['ap'],1,0);
$pdf->Cell(25,8,$item['la'],1,0);
$pdf->Cell(25,8,$item['tr'],1,0);
$pdf->Cell(35,8,$item['tra'],1,1);
}
}
Having never worked with php before… I need some help!
Question:
What’s wrong with my loop and variables assignment. The assigment seems to work, but the blank page doesn’t tell me what’s wrong in my loop…
THANKS!
It should be foreach instead of for