Below is a simple function for PHP to check if a number is a valid Lithuanian personal identification number. As I made it for Codeigniter 4, it is included in a class (that can be easily integrated into CI4 framework), but if you want, you can use it as a standalone function.
By default it does not consider valid the numbers with future dates (as people at the time of validation cannot have such numbers). But it might be modified easily to allow for such theoretical numbers.
To check an ID outside the Codeigniter 4 validation context, you would do something like this:
$check = new CustomRules(); $error = ''; $code = '36709010185'; echo $check->valid_lt_id($code, $error) ? 'ok' : $error; // prints "Lithuanian Personal Identification Number is not valid: // wrong control number" $error = ''; $code = '36709010186'; echo $check->valid_lt_id($code, $error) ? 'ok' : $error; // prints "ok"