Luhn (modulus 10 or mod 10 algorithm) for PHP
- PHP 8.1+
composer require selective/luhn
<?php
use Selective\Luhn\Luhn;
$luhn = new Luhn();
echo $luhn->create('7992739871'); // 3
<?php
use Selective\Luhn\Luhn;
$luhn = new Luhn();
$luhn->validate('79927398713'); // true
$luhn->validate('79927398710'); // false
- MIT