当前位置:Gxlcms > PHP教程 > 循环类型

循环类型

时间:2021-07-01 10:21:17 帮助过:5人阅读

Types of loops 循环类型。
  1. $files = array ('index.php', 'reports.php', 'welcome');
  2. echo "This is how foreach works
  3. ";
  4. foreach($files as $file){
  5. echo $file."
  6. ";
  7. };
  8. echo "
  9. ";
  10. echo "This is how for works
  11. ";
  12. for($index = 0; $index < count($files); $index++){
  13. //echo "Index = ".$index."
  14. ";
  15. echo "File = ".$files[$index]."
  16. ";
  17. } Play Angry Birds
  18. echo "
  19. ";
  20. echo "This is how while works
  21. ";
  22. $index = 0;
  23. while($index
  24. //echo "Index = ".$index."
    ";
  25. echo "File = ".$files[$index]."
  26. ";
  27. $index++;
  28. }
  29. ?>

人气教程排行