Skip to content

Commit

Permalink
Rework the examples for continue (#2367)
Browse files Browse the repository at this point in the history
Co-authored-by: Kamil Tekiela <[email protected]>
  • Loading branch information
aleksandr-shevchenko and kamil-tekiela authored Aug 12, 2023
1 parent 390278d commit 16389a7
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions language/control-structures/continue.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,29 +33,63 @@
<programlisting role="php">
<![CDATA[
<?php
$arr = ['zero', 'one', 'two', 'three', 'four', 'five', 'six'];
foreach ($arr as $key => $value) {
if (!($key % 2)) { // skip even members
if (0 === ($key % 2)) { // skip members with even key
continue;
}
do_something_odd($value);
echo $value . "\n";
}
?>
]]>
</programlisting>
&examples.outputs;
<screen>
<![CDATA[
one
three
five
]]>
</screen>
<programlisting role="php">
<![CDATA[
<?php
$i = 0;
while ($i++ < 5) {
echo "Outer<br />\n";
echo "Outer\n";
while (1) {
echo "Middle<br />\n";
echo "Middle\n";
while (1) {
echo "Inner<br />\n";
echo "Inner\n";
continue 3;
}
echo "This never gets output.<br />\n";
echo "This never gets output.\n";
}
echo "Neither does this.<br />\n";
echo "Neither does this.\n";
}
?>
]]>
</programlisting>
&examples.outputs;
<screen>
<![CDATA[
Outer
Middle
Inner
Outer
Middle
Inner
Outer
Middle
Inner
Outer
Middle
Inner
Outer
Middle
Inner
]]>
</screen>
</informalexample>
</para>
<para>
Expand Down

0 comments on commit 16389a7

Please sign in to comment.