I use brackets when using foreach loops. What is endforeach for?
It's mainly so you can make start and end statements clearer when creating HTML in loops:
while ($record = mysql_fetch_assoc($rs)): ?>
if (!$record['deleted']): ?>
foreach ($display_fields as $field): ?>
= $record[$field] ?>
endforeach; ?>
else: ?>
record = $record['id'] ?> has been deleted
endif; ?>
endwhile; ?>
versus
while ($record = mysql_fetch_assoc($rs)) { ?>
if (!$record['deleted']) { ?>
foreach ($display_fields as $field) { ?>
= $record[$field] ?>
} ?>
} else { ?>
record = $record['id'] ?> has been deleted
} ?>
} ?>
Hopefully my example is sufficient to demonstrate that once you have several layers of nested loops, and the indenting is thrown off by all the PHP open/close tags and the contained HTML (and maybe you have to indent the HTML a certain way to get your page the way you want), the alternate syntax (endforeach) form can make things easier for your brain to parse. With the normal style, the closing } can be left on their own and make it hard to tell what they're actually closing.