-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNid.php
More file actions
78 lines (44 loc) · 1.76 KB
/
Copy pathNid.php
File metadata and controls
78 lines (44 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/*
** Name : Get Data From NID
*/
function nid_to_data($nID){
$gov = [
01 => 'القاهرة', 02 => 'الاسكندرية', 03 => 'بورسعيد', 04 => 'السويس',
11 => 'دمياط', 12 => 'الدقهلية' , 13 => 'الشرقية', 14 => 'القليوبية',
15 => 'كفر الشيخ', 16 => 'الغربية' , 17 => 'المنوفية', 18 => 'البحيرة',
19 => 'الاسماعلية', 21 => 'الجيزة', 22 => 'بني سويف' , 23 => 'الفيوم',
24 => 'المنيا', 25 => 'اسيوط', 26 => 'سوهاج' , 27 => 'قنا',
28 => 'اسوان', 29 => 'الاقصر', 31 => 'البحر الاحمر' , 32 => 'الوادي الجديد',
33 => 'مطروح', 34 => 'شمال سيناء', 35 => 'جنوب سيناء' , 88 => 'خارج الجمهورية'
]; //all egy gov
if(strlen($nID) === 14):
$gender_number = substr($nID, 12,1);
if(in_array($gender_number,[1,3,5,7,9]))
{
$gender = 'ذكر';
}
elseif( in_array($gender_number,[2,4,6,8]) )
{
$gender = 'إنثي';
}
else {
$gender = 'غير معروف';
}
$t = substr($nID,0,1); //century
$yy = substr($nID,1,2); //year
$mm = substr($nID,3,2); //month
$dd = substr($nID,5,2); //day
$cc = substr($nID,7,2); //gov Code
$year = 1700 + 100 * $t + $yy;
$result = [
'birthday'=>$year.'-'.$mm.'-'.$dd,
'governorate' => (isset($gov[$cc])) ? $gov[$cc] : 'غير معروف',
'Gender' => $gender,
];
else:
$result = ['error'=>'ID Number Should Be 14'];
endif;
header('content-type: application/json');
return json_encode($result);
}