while,for循环输出九九乘法表

<?php

echo '<h1>while循环输出九九乘法表<h1>';
$i=1;
while ($i<=9) {
$j=1;
while ($j<=$i) {
echo "$j*$i=".($j*$i);
echo "&nbsp;";
$j++;
}
echo '<br>';
$i++;
}
//for循环输出九九乘法表
echo 'for循环输出九九乘法表';
echo "<hr>";
for ($a=1; $a<=9 ; $a++) {
for ($b=1; $b<=$a ; $b++) {
echo "$b*$a=".($a*$b);
echo "&nbsp";
}
echo "<br>";
}

?>

posted @ 2020-04-22 16:28  前端乔  阅读(616)  评论(0编辑  收藏  举报