Reputation: 7599
i'm trying to iterate through an array as follows:
$data = array(
"i0" => "item 0",
"i1" => "item 1",
"i2" => "item 2",
"i3" => "item 3",
"i4" => "item 4",
"i5" => "item 5"
);
foreach($data as $id=>$capt);
{
echo $id.": ".$capt."<br>";
}
i'm expecting getting 6 elements, but the foreach loop will only output the last item. any ideas why? thanks
Upvotes: 0
Views: 16
Reputation: 3457
The error is in foreach($data as $id=>$capt);
, it should not have a ;
at the end. Remove it and the loop will work.
Upvotes: 2