Home  >  Article  >  Backend Development  >  Example of using double-layer loop to implement multiplication table in PHP

Example of using double-layer loop to implement multiplication table in PHP

黄舟
黄舟Original
2017-10-24 09:20:322684browse

The following editor will bring you a PHP double-layer loop (nine-nine multiplication table).

The examples are as follows:


<?php
  echo "<table width = 800 height = 200 border = 1>";     //输出边框
  for($i=1;$i<=9;$i++)         //控制每行
  {
    echo "<tr>";               //输出一行
  for($j=1;$j<=$i;$j++)     //控制每列
  {
    echo "<td>";        //输出一列
    echo $i.&#39;*&#39;.$j.&#39;=&#39;.$i*$j;
    echo "</td>";
  }
  echo "</tr>";
  }
  echo "</table>";
?>

[Run results]

The above is the detailed content of Example of using double-layer loop to implement multiplication table in PHP. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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