Skip to content

Instantly share code, notes, and snippets.

@iammateus
Created May 24, 2020 20:33
Show Gist options
  • Save iammateus/0a08168eb5a0c9bc92a83e2d25a61c07 to your computer and use it in GitHub Desktop.
Save iammateus/0a08168eb5a0c9bc92a83e2d25a61c07 to your computer and use it in GitHub Desktop.
<?php
/**
* Validates a 2-digit area code not composed by zeroes.
* @link http://www.anatel.gov.br/legislacao/resolucoes/16-2001/383-resolucao-263.
* @return bool
*/
function validate (string $areaCode): bool
{
$areaCodes = array(
'11', '12', '13', '14', '15', '16', '17', '18', '19', '21', '22', '24',
'27', '28', '31', '32', '33', '34', '35', '37', '38', '41', '42', '43',
'44', '45', '46', '47', '48', '49', '51', '53', '54', '55', '61', '62',
'63', '64', '65', '66', '67', '68', '69', '71', '73', '74', '75', '77',
'79', '81', '82', '83', '84', '85', '86', '87', '88', '89', '91', '92',
'93', '94', '95', '96', '97', '98', '99'
);
$isValid = in_array($areaCode, $areaCodes);
return $isValid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment