What is the purpose of using preg_match in the provided PHP code snippet?

The purpose of using preg_match in the provided PHP code snippet is to check if a certain pattern exists within a given string. In this case, the code is attempting to validate whether the email address provided by the user is in a correct format by matching it against a regular expression pattern.

$email = $_POST['email'];

if (!preg_match("/^[a-zA-Z0-9+_.-]+@[a-zA-Z0-9.-]+$/", $email)) {
    echo "Invalid email address";
} else {
    echo "Email address is valid";
}