/** * checks if a Social Security Number is valid * needs the first three digits and first two digits and the * final four digits as separate integer parameters * @param int $area 3-digit group in a SSN * @param int $group 2-digit group in a SSN * @param int $serial 4-digit group in a SSN * @param array $high_groups array of highest issued group numbers * area number=>group number */ function ssnCheck($ssnCheck, $group, $serial, &$high_groups) { if (is_array($ssnCheck)) { extract($ssnCheck); } // perform trivial checks // no field should contain all zeros if (!($area && $group && $serial)) { return false; } // check if this area has been assigned yet if (!($high_group = $high_groups[$area])) { return false; } $high_group_range = Validate_US::ssnGroupRange($high_group); $group_range = Validate_US::ssnGroupRange($group); // if the assigned range is higher than this group number, we're OK if ($high_group_range > $group_range) { return true; } else { // if the assigned range is lower than the group number, that's bad if ($high_group_range < $group_range) { return false; } else { // we must be in the same range, check the actual numbers if ($high_group >= $group) { return true; } else { return false; } } } }