首页 > 代码库 > while循环案例

while循环案例

<?php
/**
 * Created by PhpStorm.
 * User: moka
 * Date: 2017/2/14
 * Time: 10:12
 */
$i = 0;
echo ‘<table width="800" border="1">‘;

while ($i<100){
    //0-9为一行
    //10-19为一行
    if($i%10 ==0){
        if($i%20 ==0){
            echo ‘<tr>‘;
        }else{
            echo ‘<tr bgcolor="#ffc0cb">‘;
        }
    }
    echo ‘<td>‘.$i.‘</td>‘;
    $i++;
    if($i%10==0){
        echo ‘</tr>‘;
    }
}
echo ‘</table>‘;
echo ‘<p>‘.‘<hr>‘;
$k = 0;
echo ‘<table width="800" border="1">‘;
while ($k<100){
    if($k%10==0){
        if($k%20==0){
            echo ‘<tr>‘;
        }else{
            echo ‘<tr bgcolor="#7fffd4">‘;
        }
    }
    echo ‘<td>‘.$k.‘</td>‘;
    $k++;
    if($k%10==0){
        echo ‘</tr>‘;
    }
}
echo ‘</table>‘;

 

技术分享

·  

 

while循环案例