Display Array as a Table (PHP)

PraitaSipiess

New Member
I am trying to print a table using PHP/HTML. Data stored inside array like this:\[code\]Array ( [id] => 1 [first_name] => mike [last_name] => lastname )\[/code\]My code is as follow. It runs and there are no error however the output is not as expected. Here is the PHP/HTML code:\[code\]<table><tr> <th>1</th> <th>2</th> <th>3</th></tr><?php foreach ($res as $item): ?><tr> <td><?php echo $item['id'] ?></td> <td><?php echo $item['first_name'] ?></td> <td><?php echo $item['last_name'] ?></td></tr><?php endforeach; ?></table>\[/code\]The result I get is the first character of the items:\[code\]1 2 31 1 1m m ml l l\[/code\]Not sure what I am doing wrong? I would really appreciate an explanation.
 
Back
Top