PHP code example of yomo / south-african-idnumber-generator
1. Go to this page and download the library: Download yomo/south-african-idnumber-generator 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/ */
yomo / south-african-idnumber-generator example snippets
use Illuminate\Support\Carbon;
use Nonsapiens\SouthAfricanIdNumberFaker;
// Example: Generate an ID for a male South African citizen born on 15 August 1995, using Carbon
$dateOfBirth = Carbon::createFromDate(1995, 8, 15);
$idNumber1 = RsaIdNumber::generateRsaIdNumber($dateOfBirth, 'm', true);
// Example: Generate for a female, random date of birth, non-citizen
$idNumber2 = RsaIdNumber::generateRsaIdNumber(null, 'f', false);
$idNumber = new RsaIdNumber('8208015009088'); # This will also accept ID numbers with spaces
if ($idNumber->isValid()) {
echo "This ID number is {$idNumber->gender()}";
} else {
echo 'Invalid ID number';
}