Home  >  Article  >  Backend Development  >  Basic application of for loop in PHP: Nine-Nine Multiplication Table

Basic application of for loop in PHP: Nine-Nine Multiplication Table

高洛峰
高洛峰Original
2016-11-30 11:52:541359browse

The code is as follows:

<?php 
/* 
*打印乘法口绝表 
*/ 
echo "九灵九乘法口绝表<br><br><br>"; 
echo "<table>"; 
for($i=1;$i<=9;$i++){ 
echo "<tr>"; 
for($j=1;$j<=$i;$j++){ 
echo "<td>".$j."*".$i."=".($j*$i)."</td>"; 
} 
echo "</tr>"; 
} 
echo "</table>"; 
echo "<br><br><br><br><br><br>"; 
echo "<table>"; 
for($i=1;$i<=9;$i++){ 
echo "<tr>"; 
for($j=$i;$j<=9;$j++){ 
echo "<td>".$i."*".$j."=".($j*$i)."</td>"; 
} 
echo "</tr>"; 
} 
echo "</table>"; 
?>


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