CKTIS / PHP
Keyword endwhile
Close a colon-style while loop.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
while ($condition): /* body */ endwhile;Close a colon-style while loop. On reaching endwhile execution returns to the condition before another pass. This form can surround template text; a false initial condition skips the whole body. Changing state can terminate the loop through its condition. Even with constant true, break or return can exit.
$n=3; $seen=[];
while($n>0): $seen[]=$n; $n-=2; endwhile;
echo json_encode($seen);
[3,1]
Examples
<?php
$n=3; $seen=[];
while($n>0): $seen[]=$n; $n-=2; endwhile;
echo json_encode($seen);
Result
[3,1]