<?php
function total($array = []): int {
$total = 0;
foreach ($array as &$value) {
$total += $value['quantity'];
}
return $total;
}
echo total([
[
'position' => 'книга по php',
'quantity' => 1,
],
[
'position' => 'Мышь беспроводная',
'quantity' => 12,
]
]);