$resourses = [
'gold' => 1000,
'silver' => 100,
'bronze' => 1,
];
$coins = 120;
$result = [];
foreach ($resourses as $k => $v) {
$result[$k] = intdiv($coins, $v);
$coins -= $result[$k] * $v;
}
$result['coins'] = $coins;
print_r($result);