@break and @continue - Loop Control
The @break
and @continue
directives in Ahmed PHP Template Engine allow you to control the flow of loops by either exiting the loop entirely (@break
) or skipping the current iteration (@continue
).
Syntax
@break
exits the loop immediately.@continue
skips the current iteration and moves to the next one.
Example
Output
(The loop stops when number == 3
.)
Using @continue
@continue
Output
(The number 2
is skipped.)
Notes
@break
is useful when you need to stop a loop early based on a condition.@continue
is helpful when you want to skip certain iterations without stopping the loop.Both directives work inside
@for
,@foreach
, and@while
loops.
Previous@unless - Conditional Rendering for False ValuesNextString Case Conversion - @strtoupper, @strtolower, and @ucfirst
Last updated