Q: Function each() has been DEPRECATED as of PHP 7.2.0 How can I update my code to avoid using function each()?
if (count($HTTP_POST_VARS)) {
       while (list($key, $val) = each($HTTP_POST_VARS)) {
       print "<input type=\"hidden\" name=\"$key\" value=\"$val\">\n";
      }
}

I tried with this solution but no go:
if (count($HTTP_POST_VARS)) {
           foreach ($HTTP_POST_VARS as $key => $val) {
           print "<input type=\"hidden\" name=\"$key\" value=\"$val\">\n";
          }
    }


A: You can use $_POST
if (count($_POST)) {
  foreach ($_POST as $key => $val) {
    print "<input type=\"hidden\" name=\"$key\" value=\"$val\">\n";
  }
}

See https://www.php.net/manual/en/reserved.variables.post.php for more info

A: list($key, $val) = each($HTTP_POST_VARS)
change to
function a_each(&$arr){
    $key = key($arr);
    if (!$key)
        return false;
    $val = current($arr);
    next($arr);
    return array($key, $val);
}

list($key, $val) = each($HTTP_POST_VARS);

