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

高洛峰
Release: 2023-03-01 12:32:02
Original
1395 people have browsed it

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>"; 
?>
Copy after login


Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!