$arr = array(1,2,3,4,5); foreach ($arr as $v){ switch ($v){ case 1: echo 1; break; case 2: echo 2; break; } }
break不會直接結束循環。it
若是不肯定,break是否會直接結束循環,執行以上代碼便可驗證。foreach