JavaScript Luhn modulus implementation

The following luhn_check() function is a small JavaScript function which checks whether a number is a valid based on the Luhn algoritm. One common example of use is with credit and debit card numbers. This function may be used to check for valid credit card numbers, however additional checks may be desired, such as card prefix and length checks.

There’s a…

Posted in: Code Snippets by Plan Zero 4 Comments

PHP Luhn modulus implementation

The following luhn_check() function is a small PHP function which checks whether a number is a valid based on the Luhn algorithm. One common example of use is with credit and debit card numbers. This function may be used to check for valid credit card numbers, however additional checks may be desired, such as card prefix and length checks.


<?php
/* Luhn…

Posted in: Code Snippets by Plan Zero 5 Comments