Home > Backend Development > PHP Problem > How to write 10 rows and 10 columns using for loop in PHP

How to write 10 rows and 10 columns using for loop in PHP

藏色散人
Release: 2023-02-25 13:34:02
Original
6071 people have browsed it

How to write 10 rows and 10 columns using for loop in PHP

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=&#39;border-collapse: collapse&#39;>";
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>";
?>
Copy after login

The output result is like:

How to write 10 rows and 10 columns using for loop in PHP

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!

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template