#include <infodrom.style>

<page title="Infodrom Oldenburg Tools">

<h2>IBAN calculation for German bank accounts</h2>

<p>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.</p>

<pre>
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);
}
</pre>

</page>

# Local variables:
# mode: indented-text
# end:
