PHP endforeach Keyword

PHP endswitch Keyword
PHP endfor Keyword

In this article, you will learn how to end the foreach block in PHP. The endforeach keyword in PHP is used to close the code block of a foreach loop which was started using the foreach(…): syntax.

examples of the ENDFOREACH keyword

Example 1. In this example, we close a foreach loop block.

<?php
$cars = ["Ford", "Volvo", "BMW"];
foreach($cars as $car):
  echo "$car <br>";
endforeach;
?>
PHP endswitch Keyword
PHP endfor Keyword
en English
X
Scroll to Top