How to write 10 rows and 10 columns using a for loop in php?
php uses a for loop to implement a table with 10 rows and 10 columns:
The code is like:
<?php echo "<table border =\"1\" style='border-collapse: collapse'>"; for ($row=1; $row <= 10; $row++) { echo "<tr> \n"; for ($col=1; $col <= 10; $col++) { $p = $col * $row; echo "<td>$p</td> \n"; } echo "</tr>"; } echo "</table>"; ?>
The output result is like:
Note: PHP for loop executes the code block a specified number of times.
For more PHP knowledge, please visit PHP Chinese website!
The above is the detailed content of How to write 10 rows and 10 columns using for loop in PHP. For more information, please follow other related articles on the PHP Chinese website!