codingtcher.com
Theme Night
Home
Login

Pan card validation in php

Home » Tutorial Post » Pan card validation in php
function panCardValid($pannumber){
	$pattern = '/^([A-Z]){5}([0-9]){4}([A-Z]){1}?$/';
	$result = preg_match($pattern, $pannumber);
	if ($result) {
		$findme = ucfirst(substr($pannumber, 3, 1));
		$mystring = 'CPHFATBLJG';
		$pos = strpos($mystring, $findme);
		if ($pos === false) {
			return false;
		} else {
			return true;
		}
	} else {
		return false;
	}
}

if(panCardValid("ALWPG5809L")==false){
    echo "Pan card no is invalid!";
} else{
    echo "Pan card no is valid!";
}

Related Post