IBAN calculation for German bank accounts
Here's a small PHP function for calculation the new IBAN based on old German BLZ and account number. It's in the public domain. Feel free to use.
function calc_iban($blz, $kto)
{
$country_code = 'DE';
$bban = str_replace(' ', '0', sprintf('%8s%10s', $blz, $kto));
$num_country_code = sprintf('%s%s00', ord(substr($country_code,0,1)) - ord('A') + 10, ord(substr($country_code,1,1)) - ord('A') + 10);
$checkstring = sprintf('%s%s', $bban, $num_country_code);
$check = 98 - bcmod($checkstring, '97');
return sprintf('%s%02d%s', $country_code, $check, $bban);
}