【php-05循环语句】
在 PHP 中,我们有以下循环语句:
- while - 只要指定条件为真,则循环代码块
- do...while - 先执行一次代码块,然后只要指定条件为真则重复循环
- for - 循环代码块指定次数
- foreach - 遍历数组中的每个元素并循环代码块
<?php
$colors = array("red","green","blue","yellow");
foreach ($colors as $value) {
echo "$value <br>";
}
?>
结果:
red
green
blue
yellow

浙公网安备 33010602011771号