<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/language.control-structures.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'uk',
  ),
  'this' => 
  array (
    0 => 'control-structures.continue.php',
    1 => 'continue',
    2 => 'continue',
  ),
  'up' => 
  array (
    0 => 'language.control-structures.php',
    1 => 'Control Structures',
  ),
  'prev' => 
  array (
    0 => 'control-structures.break.php',
    1 => 'break',
  ),
  'next' => 
  array (
    0 => 'control-structures.switch.php',
    1 => 'switch',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'language/control-structures/continue.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="control-structures.continue" class="sect1">
 <h2 class="title">continue</h2>
 <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p>
 <p class="simpara">
  <code class="literal">continue</code> is used within looping structures to
  skip the rest of the current loop iteration and continue execution
  at the condition evaluation and then the beginning of the next iteration.
 </p>
 <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
  <span class="simpara">
   In PHP the
   <a href="control-structures.switch.php" class="link">switch</a> statement is
   considered a looping structure for the purposes of
   <code class="literal">continue</code>. <code class="literal">continue</code> behaves like
   <code class="literal">break</code> (when no arguments are passed) but will
   raise a warning as this is likely to be a mistake. If a 
   <code class="literal">switch</code> is inside a loop,
   <code class="literal">continue 2</code> will continue with the next iteration
   of the outer loop.
  </span>
 </p></blockquote>
 <p class="simpara">
  <code class="literal">continue</code> accepts an optional numeric argument
  which tells it how many levels of enclosing loops it should skip
  to the end of. The default value is <code class="literal">1</code>, thus skipping
  to the end of the current loop.
 </p>
 <p class="para">
  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$arr </span><span style="color: #007700">= [</span><span style="color: #DD0000">'zero'</span><span style="color: #007700">, </span><span style="color: #DD0000">'one'</span><span style="color: #007700">, </span><span style="color: #DD0000">'two'</span><span style="color: #007700">, </span><span style="color: #DD0000">'three'</span><span style="color: #007700">, </span><span style="color: #DD0000">'four'</span><span style="color: #007700">, </span><span style="color: #DD0000">'five'</span><span style="color: #007700">, </span><span style="color: #DD0000">'six'</span><span style="color: #007700">];<br />foreach (</span><span style="color: #0000BB">$arr </span><span style="color: #007700">as </span><span style="color: #0000BB">$key </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$value</span><span style="color: #007700">) {<br />    if (</span><span style="color: #0000BB">0 </span><span style="color: #007700">=== (</span><span style="color: #0000BB">$key </span><span style="color: #007700">% </span><span style="color: #0000BB">2</span><span style="color: #007700">)) { </span><span style="color: #FF8000">// skip members with even key<br />        </span><span style="color: #007700">continue;<br />    }<br />    echo </span><span style="color: #0000BB">$value </span><span style="color: #007700">. </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <p class="para">Подані вище приклади
виведуть:</p>
   <div class="example-contents screen">
<div class="cdata"><pre>
one
three
five
</pre></div>
   </div>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$i </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">;<br />while (</span><span style="color: #0000BB">$i</span><span style="color: #007700">++ &lt; </span><span style="color: #0000BB">5</span><span style="color: #007700">) {<br />    echo </span><span style="color: #DD0000">"Outer\n"</span><span style="color: #007700">;<br />    while (</span><span style="color: #0000BB">1</span><span style="color: #007700">) {<br />        echo </span><span style="color: #DD0000">"Middle\n"</span><span style="color: #007700">;<br />        while (</span><span style="color: #0000BB">1</span><span style="color: #007700">) {<br />            echo </span><span style="color: #DD0000">"Inner\n"</span><span style="color: #007700">;<br />            continue </span><span style="color: #0000BB">3</span><span style="color: #007700">;<br />        }<br />        echo </span><span style="color: #DD0000">"This never gets output.\n"</span><span style="color: #007700">;<br />    }<br />    echo </span><span style="color: #DD0000">"Neither does this.\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <p class="para">Подані вище приклади
виведуть:</p>
   <div class="example-contents screen">
<div class="cdata"><pre>
Outer
Middle
Inner
Outer
Middle
Inner
Outer
Middle
Inner
Outer
Middle
Inner
Outer
Middle
Inner
</pre></div>
   </div>
  </div>
 </p>
 <p class="para">
  Omitting the semicolon after <code class="literal">continue</code> can lead to
  confusion. Here&#039;s an example of what you shouldn&#039;t do.
 </p>
 <p class="para">
  <div class="informalexample">
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">for (</span><span style="color: #0000BB">$i </span><span style="color: #007700">= </span><span style="color: #0000BB">0</span><span style="color: #007700">; </span><span style="color: #0000BB">$i </span><span style="color: #007700">&lt; </span><span style="color: #0000BB">5</span><span style="color: #007700">; ++</span><span style="color: #0000BB">$i</span><span style="color: #007700">) {<br />    if (</span><span style="color: #0000BB">$i </span><span style="color: #007700">== </span><span style="color: #0000BB">2</span><span style="color: #007700">)<br />        continue<br />    print </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$i</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

   <p class="para">
    One can expect the result to be:
   </p>
   <div class="example-contents screen">
<div class="cdata"><pre>
0
1
3
4
</pre></div>
   </div>
  </div>
 </p>
 <p class="para">
  <table class="doctable table">
   <caption><strong>Changelog for <code class="literal">continue</code></strong></caption>
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>7.3.0</td>
      <td>
       <code class="literal">continue</code> within a <code class="literal">switch</code> that is attempting to act like a <code class="literal">break</code> statement for the 
       <code class="literal">switch</code> will trigger an <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>.
      </td>
     </tr>

    </tbody>
   
  </table>

 </p>
</div><?php manual_footer($setup); ?>