luhn.php
Table of Contents
Functions
- luhn() : bool
- Validates whether a given string is a valid Luhn code (mod 10 checksum).
Functions
luhn()
Validates whether a given string is a valid Luhn code (mod 10 checksum).
luhn(string $number[, bool $lazy = false ]) : bool
The Luhn algorithm is commonly used to validate credit card numbers, IMEI numbers, and other identification codes.
Parameters
- $number : string
-
The input string to validate.
- $lazy : bool = false
-
If true, non-digit characters will be removed before validation. If false, the string must contain only digits.
Tags
Return values
bool —Returns true if the input passes the Luhn check, false otherwise.