标签:each 循环 99乘法表 pre 乘法表 php ++ val echo
<?php
echo "99乘法表<br/>";
echo "for循环<br/>";
for ($i = 1; $i <= 9; $i++) {
for ($j = 1; $j <= $i; $j++) {
echo " " . $j . "*" . $i . ‘=‘ . $i * $j . " ";
}
echo "<br/>";
}
echo "<br/><br/>";
echo "while循环<br/>";
$m = 1;
while ($m < 9) {
$m++;
$n =1;
while ($n <= $m) {
echo " " . $n . "*" . $m . ‘=‘ . $n * $m . " ";
$n++;
}
echo "<br/>";
}
echo "<br/><br/>";
echo "dowhile<br/>";
$x = 1;
do {
$y =1;
do {
echo " " . $x . "*" . $y . ‘=‘ . $x * $y . " ";
$y++;
} while ($y <= $x);
$x++;
echo "<br/>";
} while ($x <= 9);
echo "<br/><br/>";
echo "foreach<br/>";
$arr = array(1,2,3,4,5,6,7,8,9);
foreach ($arr as $key=>$val1) {
foreach ($arr as $key => $val2) {
if ($val2 <= $val1) {
echo $val1 . "*". $val2 ."=". $val1 * $val2 . " ";
}
}
echo "<br/>";
}
标签:each 循环 99乘法表 pre 乘法表 php ++ val echo
原文地址:http://www.cnblogs.com/wzybnzy/p/7490668.html