dimanche 11 octobre 2020

Store a loop statement's result in a variable in PHP

echo "<table border =\"1\" style='border-collapse: collapse'>";

for ($i = 0; $i <= $col_count; $i++) {
  echo "<tr>\n";
  for ($j = 0; $j <= $row_count; $j++) {
    $p = $data2[$i][$j];
    echo "<td>$p</td> \n";
  }
  echo "</tr>";
}
echo "</table>";
?>

This is my code and it produces a table with 3 Columns and 6 Rows. I want the produced HTML syntax to be stored in a variable in PHP. Is there a way this is possible?




Aucun commentaire:

Enregistrer un commentaire