Hello guys I have the following problem where a fix in php
?php
$fruits = array ("Apple", "Blackberry", "Strawberry");
$tablerows = "";
foreach ($fruits as $key => $value) {
$rows = "";
$rows = '<tr>
<td>'.$value.'</td>
</tr>';
$tablerows = $rows;
}
echo $tablerows;
?>
this is the result
<tr>
<td>Strawberry</td>
</tr>
and what I expect should be like this
<tr>
<td>Apple</td>
</tr>
<tr>
<td>Blackberry</td>
</tr>
<tr>
<td>Strawberry</td>
</tr>
Anyone who can help me solve this problem would be very grateful.
.=not=. to append to a string.$rows = "";since you overwrite it on the next line.