This if is redundant, given the regex you're matching against immediately afterwards.

You can make this behaviour the 'else' of the preg_match.