What was the workaround?
Well, it's a workaround only if you're fine with single transaction per a recipient address (I was).
In such case, just sum up the amounts using a map with the destination address as the key.
Something like:
$addrs = array();
for(...) {
$destaddr = ...
$amount = ...
if (array_key_exists($destaddr, $addrs)) {
$addrs[$destaddr] += $amount;
} else {
$addrs[$destaddr] = $amount;
}
}
After this you have only single addresses in $addrs (with the amounts summed up), so just:
$rpc = 'sendmany "'.ACCOUNT.'" \'{';
$com = false;
foreach(array_keys($addrs) as $da) {
$am = round($addrs[$da], 8);
if ($am>0) {
if ($com) $rpc .= ', ';
$rpc .= '"'.$da.'":'.sprintf('%.8f',$am);
$com = true;
}
}
$rpc .= '}\'';