To concatenate some rows in the same table, you have just to extract them from their original tables and them to a table which is concatenated with the common text parts. For that, take this example :
I'll put my texts in an array :
$data = [
'Dear User2,<br> <br> Sample text <table style="border-collapse:collapse; width:100%" border="solid"> <tr> <th>TH1</th> <th>TH2</th> <th>TH3</th> </tr> <tr> <td style="width:10%"><center>1</center></td> <td style="width:20%"><center>foo1</center></td> <td style="width:20%"><center>foo1</center></td> </tr> </table> <br> Thank you, <br> Admin',
'Dear User2,<br> <br> Sample text <table style="border-collapse:collapse; width:100%" border="solid"> <tr> <th>TH1</th> <th>TH2</th> <th>TH3</th> </tr> <tr> <td style="width:10%"><center>2</center></td> <td style="width:20%"><center>foo2</center></td> <td style="width:20%"><center>foo2</center></td> </tr> </table> <br> Thank you, <br> Admin',
'Dear User2,<br> <br> Sample text <table style="border-collapse:collapse; width:100%" border="solid"> <tr> <th>TH1</th> <th>TH2</th> <th>TH3</th> </tr> <tr> <td style="width:10%"><center>3</center></td> <td style="width:20%"><center>foo3</center></td> <td style="width:20%"><center>foo3</center></td> </tr> </table> <br> Thank you, <br> Admin'
];
Common parts are :
Dear User2,<br> <br> Sample text <table style="border-collapse:collapse; width:100%" border="solid"> <tr> <th>TH1</th> <th>TH2</th> <th>TH3</th> </tr>
and
</table> <br> Thank you, <br> Admin
So if the common parts are always the same and with fixed lengths, you can use some substr() to extract what you need like this, for example :
// get common parts
$common_part_1 = substr($data[0], 0, 151);
$common_part_2 = substr($data[0], -36);
$content = '';
// concatenate all content rows
for($i = 0; $i < count($data); $i++){
$content .= get_content($data[$i]);
}
where get_content() is the function that will extract the row containing the targeted text :
function get_content($data){
return substr($data, 151 , strlen($data) - 36 - 151);
}
then
echo $common_part_1 . $content . $common_part_2;
Of course this manner is really very limited, I don't recommend you to use it but I tried to give an idea how you can do ...
The second manner, is to extract your text using regex with preg_match() function :
// extract the 1st content row
$content = get_content($data[0]);
// extract the common parts
$common_parts = str_replace($content, '##content##', $data[0]);
// concatenate all content rows
for($i = 1; $i < count($data); $i++){
$content .= get_content($data[$i]);
}
and
function get_content($data){
$pattern = '/\<\/th\>\s\<\/tr\>(.*)\<\/table\>/';
preg_match($pattern, $data, $matches);
return $matches[1];
}
then
echo str_replace('##content##', $content, $common_parts);
which will give you for both manners something like this :

Hope that can help.