I have some code which is no longer compatible with PHP 8.1 because of depracation of each() in PHP 8. Could you help me convert this block one compatible with php 8?
while ((list($key, $category) = each($this->selected_categories)) || ($i % $columns != 0)) {
if ($category && !($category->totalItemCount() || $this->params->get('config.show_empty_categories', false)))
continue;
if ($i % $columns == 0)
echo ($i > 0 ? '</div><div class="row">' : '<div class="row first-row">');
$firstcell = ($i % $columns == 0) ? 'first-cell' : null;
echo '<div class="width'.intval(100 / $columns).' '.$firstcell.'">'.$this->partial('category', compact('category')).'</div>';
$i++;
}