-
Notifications
You must be signed in to change notification settings - Fork 6
/
phpCheckPAN.php
36 lines (34 loc) · 936 Bytes
/
phpCheckPAN.php
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
<?php
/*
// Program : To check validity of a given PAN number
// Author : Ap.Muthu <apmuthu@usa.net>
// Version : 1.0
// Release Date : 2021-04-20
// Reference : https://techotut.com/pan-card-validation-php/
// : https://www.geeksforgeeks.org/how-to-validate-pan-card-number-using-regular-expression/
// Usage :
$value = "PAN Card NUMBER"; //Put your 10 character PAN card Number here
echo (checkPAN($value)) ? "Yes" : "No";
*/
function checkPAN($str) {
$str = trim($str);
if (strlen($str) <> 10) {
$msg = false;
} else {
$pattern = '/^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/';
$result = preg_match($pattern, $str);
if ($result) {
$findme = ucfirst(substr($str, 3, 1));
$mystring = 'CPHFATBLJG';
$pos = strpos($mystring, $findme);
if ($pos === false) {
$msg = false;
} else {
$msg = true;
}
} else {
$msg = false;
}
}
return $msg;
}