I have my code working to some degree as it echo's out my array to a table - but the issue is, it's echoing out all fields.
I want to display just the name, trainer and status fields. I just can't get my head around how to do it.
Array
[{
id: "8001073",
name: "Castarnie",
silk: "c20170311her/00829186.jpg",
cloth_number: "4",
jockey: "Harry Cobden",
trainer: "Robert Walford",
weight_value: "165",
weight_unit: "pounds",
form: "P-2P2PF",
bred: "GB",
last_run: "21",
status: "WINNER"
},
{
id: "7164976",
name: "Try It Sometime",
silk: "c20170311her/00026136.jpg",
cloth_number: "8",
jockey: "Mikey Hamill",
trainer: "Sheila Lewis",
weight_value: "140",
weight_unit: "pounds",
form: "654529",
bred: "IRE",
last_run: "20",
status: "LOSER"
}
]
and the PHP code looks like
<?php if (count($obj) > 0): ?>
<table>
<thead>
<tr>
<th><?php echo implode('</th><th>', array_keys(current($obj))); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($obj as $row): array_map('htmlentities', $row); ?>
<tr>
<td><?php echo implode('</td><td>', $row); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php endif; ?>