I have an array of order items, and I am collapsing the array so that duplicate lines are shown as only 1 line with " x 2" or " x 3" etc at the end of the line depending on the quantity.
The code is working but I am getting this warning/error:
Deprecated: The each() function is deprecated. This message will be suppressed on further calls...
How can I rewrite my function to work the same without using each()?
$order_lean=array_count_values($order);
$lean = array();
$str = "";
$first = 1;
while(list($key,$val) = each($order_lean)){ // <---
    array_push($lean, "$val x $key");
    if($first){
        $first = 0;
    }else{
        $str .= "\n";
    }
    $str .= "$val x $key";
}
return $str;
 
    