Simpler than you might think.
The foreach loops through the array, giving you the key and value of each item in turn.
For every item, you want to insert the Table Row construct.
For the item where the key is "ct", you want to insert some extra "stuff".
Try this:
foreach( $arr as $k => $v ){
$x .= sprintf( '<tr><td> Td %s </td><td> Td %s</td></tr>', $k, $v );
if ( 'ct' === $k )
{
$x .= $Insert_HTML_Here ;
}
}
Regards,
Phill W.