I would ...
foreach ($array as $k => $v) {
$id = substr($k, -5);
if (ctype_digit($id)) {
$len = strlen($k);
$k = substr($k, 0, $len-5);
$sku[$id][$k] = $v;
}
else $sku[$k] = $v;
}
echo '<pre>' . print_r($sku, 1) . '</pre>';
giving...
Array
(
[77777] => Array
(
[newQuantity] => 3
[newPrice] => 5
[usedQuantity] => 1
[usedPrice] => 3.99
[total] => 18.99
)
[88888] => Array
(
[newQuantity] => 0
[newPrice] => 0
[usedQuantity] => 4
[usedPrice] => 12
[total] => 48
)
[44444] => Array
(
[newQuantity] => 2
[newPrice] => 4
[usedQuantity] => 0
[usedPrice] => 3.99
[total] => 8
)
[date] => July 25 2021
[address] => 123 Anystreet Avenue
[address2] =>
[zipcode] => 90210
[city] => Beverly Hills
[state] => CA
[planet] => Mars
)