PHP endforeach Keyword

❮ PHP Keywords

Example

Close a foreach loop block:

<?php
$cars = ["Ford", "Volvo", "BMW"];
foreach($cars as $car):
  echo "$car <br>";
endforeach;
?>
Try it Yourself »

Definition and Usage

The endforeach keyword is used to close the code block of a foreach loop which was started using the foreach(...): syntax.


Related Pages

The foreach keyword.

Read more about for loops in our PHP foreach Loop Tutorial.


❮ PHP Keywords
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.