public static function phone($check, $regex = null, $country = 'all')
	{
		if (is_array($check))
		{
			extract(self::_defaults($check));
		}

		if ($regex === null)
		{
			switch ($country)
			{
				case 'us':
				case 'ca':
				case 'can': // deprecated three-letter-code
				case 'all':
					// includes all NANPA members.
					// see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
					$regex = '/^(?:(?:\+?1\s*(?:[.-]\s*)?)?';

					// Area code 555, X11 is not allowed.
					$areaCode = '(?![2-9]11)(?!555)([2-9][0-8][0-9])';
					$regex .= '(?:\(\s*' . $areaCode . '\s*\)|' . $areaCode . ')';
					$regex .= '\s*(?:[.-]\s*)?)';

					// Exchange and 555-XXXX numbers
					$regex .= '(?!(555(?:\s*(?:[.\-\s]\s*))(01([0-9][0-9])|1212)))';
					$regex .= '(?!(555(01([0-9][0-9])|1212)))';
					$regex .= '([2-9]1[02-9]|[2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)';

					// Local number and extension
					$regex .= '?([0-9]{4})';
					$regex .= '(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/';
				break;
			}
		}
		if (empty($regex))
		{
			return self::_pass('phone', $check, $country);
		}
		return self::_check($check, $regex);
	}
public static function phone($check, $regex = null, $country = 'all')
	{
		if (is_array($check))
		{
			extract(self::_defaults($check));
		}

		if ($regex === null)
		{
			switch ($country)
			{
				case 'us':
				case 'ca':
				case 'can': // deprecated three-letter-code
				case 'all':
					// includes all NANPA members.
					// see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories
					$regex = '/^(?:(?:\+?1\s*(?:[.-]\s*)?)?';

					// Area code 555, X11 is not allowed.
					$areaCode = '(?![2-9]11)(?!555)([2-9][0-8][0-9])';
					$regex .= '(?:\(\s*' . $areaCode . '\s*\)|' . $areaCode . ')';
					$regex .= '\s*(?:[.-]\s*)?)';

					// Exchange and 555-XXXX numbers
					$regex .= '(?!(555(?:\s*(?:[.\-\s]\s*))(01([0-9][0-9])|1212)))';
					$regex .= '(?!(555(01([0-9][0-9])|1212)))';
					$regex .= '([2-9]1[02-9]|[2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)';

					// Local number and extension
					$regex .= '?([0-9]{4})';
					$regex .= '(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/';
				break;
			}
		}
		if (empty($regex))
		{
			return self::_pass('phone', $check, $country);
		}
		return self::_check($check, $regex);
	}
public static function phone ( $ check , $ regex = null , $ country = 'all' ) { if ( is_array ( $ check ) ) { extract ( self :: _defaults ( $ check ) ) ; } if ( $ regex === null ) { switch ( $ country ) { case 'us' : case 'ca' : case 'can' : // deprecated three-letter-code case 'all' : // includes all NANPA members. // see http://en.wikipedia.org/wiki/North_American_Numbering_Plan#List_of_NANPA_countries_and_territories $ regex = '/^(?:(?:\+?1\s*(?:[.-]\s*)?)?' ; // Area code 555, X11 is not allowed. $ areaCode = '(?![2-9]11)(?!555)([2-9][0-8][0-9])' ; $ regex .= '(?:\(\s*' . $ areaCode . '\s*\)|' . $ areaCode . ')' ; $ regex .= '\s*(?:[.-]\s*)?)' ; // Exchange and 555-XXXX numbers $ regex .= '(?!(555(?:\s*(?:[.\-\s]\s*))(01([0-9][0-9])|1212)))' ; $ regex .= '(?!(555(01([0-9][0-9])|1212)))' ; $ regex .= '([2-9]1[02-9]|[2-9]1[02-9]|[2-9][02-9]1|[2-9][02-9]{2})\s*(?:[.-]\s*)' ; // Local number and extension $ regex .= '?([0-9]{4})' ; $ regex .= '(?:\s*(?:#|x\.?|ext\.?|extension)\s*(\d+))?$/' ; break ; } } if ( empty ( $ regex ) ) { return self :: _pass ( 'phone' , $ check , $ country ) ; } return self :: _check ( $ check , $ regex ) ; }
Check that a value is a valid phone number.

@param  string|array $check   Value to check (string or array)
@param  string       $regex   Regular expression to use
@param  string       $country Country code (defaults to 'all')
@return boolean Success
Check that a value is a valid phone number .