Here is a situation I need to display values from array through foreach loop inside variable and than echo that variable inside HTML table. Thanks in Advance. . I have checked all related links in stackoverflow some links are given below.
PHP simple foreach loop with HTML [closed]
My question is about store looping array inside a variable.. And their is no similarity in another and my question
I want my output to be this way below
I'm getting this error image given below
php filename: foreachloop.php
<?php
$arr = array("Apple","orange","strawberry");
$abc = '<table border="2">
<tr>
<th>Names</th>
</tr>
foreach($arr as $key){
<tr>
<td>'.$key.'</td>
</tr>
}
</table>';
echo $abc;
?>