What are the advantages of using preg_match() over stristr() for pattern matching in PHP?

When it comes to pattern matching in PHP, using preg_match() has several advantages over stristr(). preg_match() allows for more complex pattern matching using regular expressions, which can be useful for matching specific patterns or extracting specific parts of a string. Additionally, preg_match() provides more flexibility and control over the matching process compared to stristr(), which is limited to simple substring matching.

// Using preg_match() for pattern matching
$string = "Hello, world!";
if (preg_match("/hello/i", $string)) {
    echo "Pattern found using preg_match()!";
} else {
    echo "Pattern not found using preg_match()!";
}