This will work although when embedding PHP in HTML it is better practice to use the following form :
<table>
<?php foreach($array as $key=>$value): ?>
<tr>
<td><?php echo $key; ?></td>
</tr>
<?php endforeach; ?>
</table>
You can find the doc for the alternative syntax here : http://www.php.net/manual/en/control-structures.alternative-syntax.php