循环执行代码块指定的次数,或者当指定的条件为真时循环执行代码块。
for 循环用于您预先知道脚本需要运行的次数的情况。
for (初始值; 条件; 增量)
{
要执行的代码;
} 输出:
The number is 1
The number is 2
The number is 3
The number is 4
The number is 5 foreach 循环用于遍历数组。
foreach ($array as $value)
{
要执行代码;
} 输出:
one
two
three