public static function match($phone='') {
		if (! \is_string($phone)) {
			if (\is_numeric($phone)) {
				$phone = (string) $phone;
			}
			else {
				return false;
			}
		}

		phone::sanitize_phone($phone);
		if (false === $phone) {
			return false;
		}

		// Test the number with and without the prefix.
		$test = array($phone);
		$tmp = \ltrim($phone, '0');
		if (0 === \strpos($tmp, \strval(static::PREFIX))) {
			$test[] = \substr($tmp, \strlen(static::PREFIX));
		}

		// Do they match the patterns?
		foreach ($test as $t) {
			foreach (static::PATTERNS as $p) {
				if (\preg_match("/^($p)$/", $t)) {
					// Should match a specific type.
					$types = static::types($t);
					if (! \count($types)) {
						continue;
					}

					$out = phone::TEMPLATE;
					$out['country'] = static::CODE;
					$out['prefix'] = static::PREFIX;
					$out['region'] = static::REGION;
					$out['types'] = $types;
					$out['number'] = '+' . static::PREFIX . ' ' . static::format($t);

					return $out;
				}
			}
		}

		return false;
	}
public static function match($phone='') {
		if (! \is_string($phone)) {
			if (\is_numeric($phone)) {
				$phone = (string) $phone;
			}
			else {
				return false;
			}
		}

		phone::sanitize_phone($phone);
		if (false === $phone) {
			return false;
		}

		// Test the number with and without the prefix.
		$test = array($phone);
		$tmp = \ltrim($phone, '0');
		if (0 === \strpos($tmp, \strval(static::PREFIX))) {
			$test[] = \substr($tmp, \strlen(static::PREFIX));
		}

		// Do they match the patterns?
		foreach ($test as $t) {
			foreach (static::PATTERNS as $p) {
				if (\preg_match("/^($p)$/", $t)) {
					// Should match a specific type.
					$types = static::types($t);
					if (! \count($types)) {
						continue;
					}

					$out = phone::TEMPLATE;
					$out['country'] = static::CODE;
					$out['prefix'] = static::PREFIX;
					$out['region'] = static::REGION;
					$out['types'] = $types;
					$out['number'] = '+' . static::PREFIX . ' ' . static::format($t);

					return $out;
				}
			}
		}

		return false;
	}
public static function match ( $ phone = '' ) { if ( ! \ is_string ( $ phone ) ) { if ( \ is_numeric ( $ phone ) ) { $ phone = ( string ) $ phone ; } else { return false ; } } phone :: sanitize_phone ( $ phone ) ; if ( false === $ phone ) { return false ; } // Test the number with and without the prefix. $ test = array ( $ phone ) ; $ tmp = \ ltrim ( $ phone , '0' ) ; if ( 0 === \ strpos ( $ tmp , \ strval ( static :: PREFIX ) ) ) { $ test [ ] = \ substr ( $ tmp , \ strlen ( static :: PREFIX ) ) ; } // Do they match the patterns? foreach ( $ test as $ t ) { foreach ( static :: PATTERNS as $ p ) { if ( \ preg_match ( "/^($p)$/" , $ t ) ) { // Should match a specific type. $ types = static :: types ( $ t ) ; if ( ! \ count ( $ types ) ) { continue ; } $ out = phone :: TEMPLATE ; $ out [ 'country' ] = static :: CODE ; $ out [ 'prefix' ] = static :: PREFIX ; $ out [ 'region' ] = static :: REGION ; $ out [ 'types' ] = $ types ; $ out [ 'number' ] = '+' . static :: PREFIX . ' ' . static :: format ( $ t ) ; return $ out ; } } } return false ; }
Validate a Number

@param string $phone Phone number.
@return array|bool Phone data. False on failure.
Validate a Number