Check if index 0 exists in $matches array

Result of preg_match function can be empty array so we check if index 0 exists. Additional test also added.