PAN card validation in codeigniter

PAN card validation in codeigniter

PAN stands for Permanent Account Number in india.

This validates the alphanumeric structure of the PAN. But there is more. The last character of the first set of characters need to be the initial character of the last name of the account holder.

Pan number validation regular expression

if (!preg_match("/^([a-zA-Z]){5}([0-9]){4}([a-zA-Z]){1}?$/", $pannumber)) {
  echo "Invalid pan number";
}