mirror of
https://github.com/php/doc-en.git
synced 2026-03-23 23:32:18 +01:00
Rework the examples for continue (#2367)
Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i++ < 5) {
|
||||
echo "Outer<br />\n";
|
||||
while (1) {
|
||||
echo "Middle<br />\n";
|
||||
while (1) {
|
||||
echo "Inner<br />\n";
|
||||
continue 3;
|
||||
}
|
||||
echo "This never gets output.<br />\n";
|
||||
}
|
||||
echo "Neither does this.<br />\n";
|
||||
echo $value . "\n";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&examples.outputs;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
one
|
||||
three
|
||||
five
|
||||
]]>
|
||||
</screen>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$i = 0;
|
||||
while ($i++ < 5) {
|
||||
echo "Outer\n";
|
||||
while (1) {
|
||||
echo "Middle\n";
|
||||
while (1) {
|
||||
echo "Inner\n";
|
||||
continue 3;
|
||||
}
|
||||
echo "This never gets output.\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>
|
||||
|
||||
Reference in New Issue
Block a user