Source for file IN.php
Documentation is available at IN.php
* Specific validation for data pertaining to the Republic of India.
* This class will validate Indian:
* - Postal Codes (Zip Codes)
* - Vehicle license plate Numbers
* @author Anant Narayanan <anant@php.net>
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
* Validates an Indian Permanent Account Number (PAN) or
* Tax deduction and collection Account Number (TAN).
* @param string $number The PAN or TAN to be validated.
* @return boolean TRUE if code is valid, FALSE otherwise
return (bool) preg_match('/^[A-Z]{3}[A-Z0-9]{7}$/', $number);
* Validates an Indian Postal Code (ZIP code)
* @param string $postalCode The ZIP code to validate
* @return boolean TRUE if code is valid, FALSE otherwise
return (bool) preg_match('/^[1-9]{1}[0-9]{2}(\s|\-)?[0-9]{3}$/', $postalCode);
* Validates a state / union territory code and returns the full name of the
* state / union territory code passed.
* @param string $region 2-letter state / union territory code
* @return bool True if state code is valid, False otherwise.
* Returns the full name of a state / union territory given a valid state
* code. If state code is invalid or NULL, an array of all states is
* @param String $code 2 letter State / U.T. Code.
* @return String/Array Full name of state of code is valid, array of
$states = array ("Andaman and Nicobar Islands",
"Dadra and Nagar Haveli",
case 'AN': return $states[0 ];
case 'AP': return $states[1 ];
case 'AR': return $states[2 ];
case 'AS': return $states[3 ];
case 'BR': return $states[4 ];
case 'CH': return $states[5 ];
case 'CT': return $states[6 ];
case 'DN': return $states[7 ];
case 'DD': return $states[8 ];
case 'DL': return $states[9 ];
case 'GA': return $states[10 ];
case 'GJ': return $states[11 ];
case 'HR': return $states[12 ];
case 'HP': return $states[13 ];
case 'JK': return $states[14 ];
case 'JH': return $states[15 ];
case 'KA': return $states[16 ];
case 'KL': return $states[17 ];
case 'LD': return $states[18 ];
case 'MP': return $states[19 ];
case 'MH': return $states[20 ];
case 'MN': return $states[21 ];
case 'ML': return $states[22 ];
case 'MZ': return $states[23 ];
case 'NL': return $states[24 ];
case 'OR': return $states[25 ];
case 'PY': return $states[26 ];
case 'PB': return $states[27 ];
case 'RJ': return $states[28 ];
case 'SK': return $states[29 ];
case 'TN': return $states[30 ];
case 'TR': return $states[31 ];
case 'UL': return $states[32 ];
case 'UP': return $states[33 ];
case 'WB': return $states[34 ];
* Validate an Indian Phone number.
* Allows the following formats:
* where whitespaces, dashes and brackets may interchanged freely and 0/+ may
* be added / skipped wherever possible.
* @param string $number Phone number to validate (mobile or
* @return bool True if number is valid, False otherwise
if (substr($number, 0 , 3 )== '091' or substr($number, 0 , 3 )== '+91') {
// no numbers in India begin with 91, so safely strip country code
if (substr($number, 0 , 2 )== '91') {
if (preg_match('/^9(2|3|4|8|9)(\s)?(\-)?(\s)?[1-9]{1}[0-9]{7}$/', $number)) {
// it's a landline, with or without area code
if (preg_match('/^\(?(0[1-9]{2,5}|\d{2,5})?(\s)?(\s|\)|\-)?(\s)?(2|3|5)\d{6,7}$/',
* Validates an Indian Vehicle's license plate number.
* @param string $license The license plate number to validate.
* @return boolean TRUE if code is valid, FALSE otherwise
preg_match('/^[A-Z]{2}(\s|\-)?[0-9]{1,2}(\s|\-)?(S|C|R|V)?(\s|\-)?[A-Z]{0,2}(\s|\-)?\d{4}$/',
Documentation generated on Mon, 11 Mar 2019 14:38:26 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|