abstract:<?php$data = range(1,20);$count = count($data);//用for循環(huán)依次輸出$data數(shù)組的值/*for ($i=0; $i<$count; $i++) { echo $data[$i] . '<br>';}*///用while()循環(huán)輸出$data數(shù)組的值/*$i = 0;while ($
<?php $data = range(1,20); $count = count($data); //用for循環(huán)依次輸出$data數(shù)組的值 /*for ($i=0; $i<$count; $i++) { echo $data[$i] . '<br>'; }*/ //用while()循環(huán)輸出$data數(shù)組的值 /*$i = 0; while ($i < $count) { echo $data[$i] . '<br>'; $i++; }*/ //用do while()輸出$data數(shù)組的值,這個(gè)循環(huán)是不管條件成不成立,都會(huì)執(zhí)行一次循環(huán)體內(nèi)的語句 /*$i = 0; do { echo $data[$i] . '<br>'; $i++; } while($i < $count);*/ //用foreach 來循環(huán)輸出$data數(shù)組的值: 這個(gè)是專門用來遍歷數(shù)組的循環(huán) foreach ($data as $key => $value) { echo '$data數(shù)組的鍵是:' . $key . ' 值是:' . $value . '<br>'; }
Correcting teacher:查無此人Correction time:2019-03-15 09:14:12
Teacher's summary:完成的不錯(cuò)。foreach 可以循環(huán)關(guān)聯(lián)數(shù)組,其他的循環(huán)屬于計(jì)數(shù)循環(huán)。繼續(xù)加油