I understand that the each function() is deprecated in PHP 8.0.
Updated: I'm getting a Fatal error: Uncaught Error: Call to undefined function each() line 742 - [line 742 is this line in the code snippet below: list($orig,$values) = each($where); ]
I am trying to replace it in the below code with foreach() as suggested in this post, but I am not experienced enough in PHP or coding to achieve this. Can anyone help?
public function getMetaboxConfig($type) {
static $cache;
if (!empty($cache[$type])) {
return $cache[$type];
}
do_action("pe_theme_metabox_config_$type");
$config =& PeGlobal::$config;
$metaboxes = PeGlobal::$config["metaboxes"];
$pmboxes = empty($config["metaboxes-$type"]) ? null : $config["metaboxes-$type"];
if ($custom = apply_filters("pe_theme_metabox_$type",$pmboxes)) {
//print_r(array_keys(PeGlobal::$config["metaboxes-view"]));
$keys = array_keys($custom);
foreach ( $custom as $key => $value ) {
$metaboxes[$key] = $custom[$key];
$where =& $metaboxes[$key]["where"];
list($orig,$values) = each($where);
if ($orig != $type) {
unset($where[$orig]);
$where[$type] = $values;
}
}
}
$cache[$type] = $metaboxes;
return $metaboxes;
}
The error I am seeing: