PHP code example of designbycode / south-african-id-validator
1. Go to this page and download the library: Download designbycode/south-african-id-validator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
designbycode / south-african-id-validator example snippets
$validator = new SouthAfricanIdValidator();
$idNumber = '9404260051081';
if ($validator->isValid($idNumber)) {
echo 'ID number is valid';
} else {
echo 'ID number is invalid';
}
$idNumber = '9404260051081';
$parsedData = $validator->parse($idNumber);
print_r($parsedData);
$idNumber = '9404260051081';
if ($validator->isMale($idNumber)) {
echo 'Male';
} else {
echo 'Female';
}
$idNumber = '9404260051081';
if ($validator->isSACitizen($idNumber)) {
echo 'SA Citizen';
} else {
echo 'Permanent Resident';
}