Skip to content

Instantly share code, notes, and snippets.

@tsnoad
Last active August 29, 2015 14:03
Show Gist options
  • Save tsnoad/1123ad63b731d7d8e970 to your computer and use it in GitHub Desktop.
Save tsnoad/1123ad63b731d7d8e970 to your computer and use it in GitHub Desktop.
foxtrot customer id check digit algorithm
# php -r '<?php $i = 500295; $reg = 0; $xi = strrev($i); for($j=0;$j<strlen($xi);$j++) { $reg += substr($xi, $j, 1)*pow(2,$j+1); } var_dump($i."\t".($reg)."\t".fmod(fmod((11-fmod($reg,11)),11),10));'
<?php
for ($i=1;$i<100;$i++) {
$reg = 0;
$xi = strrev($i);
for($j=0;$j<strlen($xi);$j++) {
$reg += substr($xi, $j, 1)*pow(2,$j+1);
}
var_dump($i."\t".($reg)."\t".fmod(fmod((11-fmod($reg,11)),11),10));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment