PHP code example of abdelazizomar / egyption-national-id-extractor

1. Go to this page and download the library: Download abdelazizomar/egyption-national-id-extractor 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/ */

    

abdelazizomar / egyption-national-id-extractor example snippets


composer 

// Intitialize CitizenNationalIdExtractor class
$citizenData = new CitizenNationalIdExtractor(nationalId: "29803050202393");

// To get citizen century code
$citizenData->getCitizenCenturyCode();

//or you can use null-safe operator to make sure that national id is correct equal (14 number) and the output may be (null|int)
$citizenData->verifyCitizen()?->getCitizenCenturyCode();

int(2)

// To get citizen goverment code
$citizenData->getCitizenGovermentCode();

//or you can use null-safe operator to make sure that national id is correct equal (14 number) and the output may be (null|string)
$citizenData->verifyCitizen()?->getCitizenGovermentCode();

string(2) "02"

// To get citizen Goverment
$citizenData->GetCitizenGoverment(code: citizenData->getCitizenGovermentCode());

//or you can use null-safe operator to make sure that national id is correct equal (14 number) and the output may be (null|string)
$citizenData->verifyCitizen()?->GetCitizenGoverment(code: citizenData->getCitizenGovermentCode());

string(10) "Alexandria"

// To get citizen birthday year
$citizenData->getCitizenBirthdayYear();

//or you can use null-safe operator to make sure that national id is correct equal (14 number) and the output may be (null|int)
$citizenData->verifyCitizen()?->getCitizenBirthdayYear();

int(1998)

// To get citizen birthday month
$citizenData->getCitizenBirthdayMonth();

//or you can use null-safe operator to make sure that national id is correct equal (14 number) and the output may be (null|string)
$citizenData->verifyCitizen()?->getCitizenBirthdayMonth();

string(2) "03"

// To get citizen birthday day
$citizenData->getCitizenBirthdayMonth();

//or you can use null-safe operator to make sure that national id is correct equal (14 number) and the output may be (null|string)
$citizenData->verifyCitizen()?->getCitizenBirthday();

string(2) "05"

// To get citizen gender
$citizenData->getCitizenGender();

//or you can use null-safe operator to make sure that national id is correct equal (14 number) and the output may be (null|string)
$citizenData->verifyCitizen()?->getCitizenGender();

string(4) "Male"

// To get citizen all information
$citizenData->getCitizenInfo();

//or you can use null-safe operator to make sure that national id is correct equal (14 number) and the output may be (null|array)
$citizenData->verifyCitizen()?->getCitizenInfo();

array(3) {
  ["DateOfBirth"]=>
  string(10) "1998/03/05"
  ["Gender"]=>
  string(4) "Male"
  ["Town"]=>
  string(10) "Alexandria"
}