第一种for{}eles{}:
echo "
for ($i = 1; $i <= 5; $i++){
if($i % 2 == 0){
echo ‘
‘;}else{
echo ‘
‘;}
for ($j = 1; $j<= 8; $j++){
echo ‘
‘.$i * $j.‘‘;}
echo ‘
‘;}
echo ‘
‘;?>
第二种方法while
echo "
$l = 1;
while ($l <= 5) {
if ($l % 2 == 0) {
echo ‘
‘;}else{
‘
‘;}
$m = 1;
while ($m <= 8) {
echo ‘
‘.$l * $m.‘‘;$m++;
}
echo ‘
‘;$l++;
}
?>
第三种方法do{}while{}
echo "
$k = 1;
do{
if($k % 2 == 0){
echo ‘
‘;}else{
echo ‘
‘;}
$n = 1;
while ($n <=8) {
echo ‘
‘.$k * $n .‘‘;$n++;
}
echo ‘
‘;$k++;
}while($k <= 5);
?>
原文:http://www.cnblogs.com/tiny-bj/p/3812970.html