title: How can I update code that uses the deprecated each() function?
body: <p>With PHP 7.2, <code>each</code> is deprecated. <a href="http://php.net/manual/en/function.each.php" rel="noreferrer">The documentation</a> says:</p>
  <blockquote>
  <p><strong>Warning</strong> This function has been DEPRECATED as of PHP 7.2.0. Relying on this function is highly discouraged.</p>
  </blockquote>
  <p>How can I update my code to avoid using it? Here are some examples:</p>
  <ol>
  <li>
  <pre><code>$ar = $o-&gt;me;
  reset($ar);
  list($typ, $val) = each($ar);
  </code></pre>
  </li>
  <li>
  <pre><code>$out = array('me' =&gt; array(), 'mytype' =&gt; 2, '_php_class' =&gt; null);
  $expected = each($out);
  </code></pre>
  </li>
  <li>
  <pre><code>for(reset($broken);$kv = each($broken);) {...}
  </code></pre>
  </li>
  <li>
  <pre><code>list(, $this-&gt;result) = each($this-&gt;cache_data);
  </code></pre>
  </li>
  <li>
  <pre><code>// iterating to the end of an array or a limit &gt; the length of the array
  $i = 0;
  reset($array);
  while( (list($id, $item) = each($array)) || $i &lt; 30 ) {
      // code
      $i++;
  }
  </code></pre>
  </li>
  </ol>
  <p>When I execute the code on PHP 7.2 I receive the following error:</p>
  <blockquote>
  <p>Deprecated: The each() function is deprecated. This message will be suppressed on further calls</p>
  </blockquote>