Validate_FI::pin
Synopsis
mixed Validate_FI::pin
(
string $number
,
bool $info
)
Description
Validate Personal Identity Number (HETU).
The Finnish PIN number (HETU) aka Social Security Number (SSN) is a 11 digit number with birthdate as ddmmyycxxxy where c is century, xxx is a three digit individual number and the last digit is a control number (y).
If xxx is odd it's a male PIN number and if even a female.
Return gender (Male or Female) and date of birth (YYYY-MM-DD) in array if PIN is valid, is available by switching $info (2nd parameter) to true.
Example: 010101-123N would be a male and born in 1st of January 1901.
Parameter
-
string
$number
-
PIN number to be validated
-
boolean
$info
-
optional; Return gender and date of birth on success
Return value
mixed - Returns true or false if $info = false or gender (Male or Female) and date of birth (YYYY-MM-DD) in array if PIN is valid, false otherwise
Example
Using pin() in default mode
<?php
// Include the package
require_once 'Validate/FI.php';
$pin = '010101-123N';
if ( Validate_FI::pin($pin) ) {
print 'Valid';
} else {
print 'Not valid!';
}
?>
Using pin() with $info
= TRUE
<?php
// Include the package
require_once('Validate/FI.php');
$pin = '010101-123N';
if ( $userinfo = Validate_FI::pin($pin, true) ) {
print_r($userinfo);
} else {
print 'Not valid!';
}
?>
Output:
Array
(
[0] => Male
[1] => 1901-01-01
)