Till Wehowski - 2011-03-11 19:02:28
Implementing applications: http://www.webfan.de/Convert.html#weLuhn
I added the possibillity to validate alphanumerics:
function calculate($str) {
$this->numstr = $str;
$this->wrkstr = str_replace($this->chr2rm, '', $str); // remove separators
//ALPHANUMERICS:
$this->wrkstr = str_ireplace('a', '10', $this->wrkstr);
$this->wrkstr = str_ireplace('b', '11', $this->wrkstr);
$this->wrkstr = str_ireplace('c', '12', $this->wrkstr);
$this->wrkstr = str_ireplace('d', '13', $this->wrkstr);
$this->wrkstr = str_ireplace('e', '14', $this->wrkstr);
$this->wrkstr = str_ireplace('f', '15', $this->wrkstr);
$this->wrkstr = str_ireplace('g', '16', $this->wrkstr);
$this->wrkstr = str_ireplace('h', '17', $this->wrkstr);
$this->wrkstr = str_ireplace('i', '18', $this->wrkstr);
$this->wrkstr = str_ireplace('j', '19', $this->wrkstr);
$this->wrkstr = str_ireplace('k', '20', $this->wrkstr);
$this->wrkstr = str_ireplace('l', '21', $this->wrkstr);
$this->wrkstr = str_ireplace('m', '22', $this->wrkstr);
$this->wrkstr = str_ireplace('n', '23', $this->wrkstr);
$this->wrkstr = str_ireplace('o', '24', $this->wrkstr);
$this->wrkstr = str_ireplace('p', '25', $this->wrkstr);
$this->wrkstr = str_ireplace('q', '26', $this->wrkstr);
$this->wrkstr = str_ireplace('r', '27', $this->wrkstr);
$this->wrkstr = str_ireplace('s', '28', $this->wrkstr);
$this->wrkstr = str_ireplace('t', '29', $this->wrkstr);
$this->wrkstr = str_ireplace('u', '30', $this->wrkstr);
$this->wrkstr = str_ireplace('v', '31', $this->wrkstr);
$this->wrkstr = str_ireplace('w', '32', $this->wrkstr);
$this->wrkstr = str_ireplace('x', '33', $this->wrkstr);
$this->wrkstr = str_ireplace('y', '34', $this->wrkstr);
$this->wrkstr = str_ireplace('z', '35', $this->wrkstr);
$this->wrkstr = str_ireplace('ä', '101', $this->wrkstr);
$this->wrkstr = str_ireplace('ö', '102', $this->wrkstr);
$this->wrkstr = str_ireplace('ü', '103', $this->wrkstr);
Regards,
Till Wehowski
Webfan.de