abstract:<?php $array = ['张三','李四','王二麻子',123,'abc']; $count = count($array); echo "<h3>for遍历</h3>"; for($i = 0;$i&n
<?php $array = ['张三','李四','王二麻子',123,'abc']; $count = count($array); echo "<h3>for遍历</h3>"; for($i = 0;$i < $count; $i++){ echo $array[$i]."<br>"; }; echo "<h3>while遍历</h3>"; $j = 0; while($j<count($array)){ echo $array[$j]."<br>"; $j++; }; echo "<h3>foreach遍历</h3>"; foreach($array as $key=>$value ){ echo $key."=>".$value."<br>"; } ?>
for循环与while分别都是计数循环,foreach循环更适用于数组的遍历。
Correcting teacher:查无此人Correction time:2019-05-05 09:31:57
Teacher's summary:完成的不错。for和while都是计算循环。foreach是数组循环。继续加油。