What is the difference between using eregi() and preg_match() in PHP for pattern matching?

The main difference between eregi() and preg_match() in PHP for pattern matching is that eregi() performs a case-insensitive match, while preg_match() requires the use of regular expressions and allows for more advanced pattern matching. If you need to perform a simple case-insensitive match, eregi() can be used. However, if you need more flexibility and control over the pattern matching process, preg_match() is recommended.

// Using preg_match() for pattern matching
$string = "Hello World";
$pattern = "/hello/i"; // Case-insensitive match for "hello"
if(preg_match($pattern, $string)) {
    echo "Pattern found using preg_match()";
} else {
    echo "Pattern not found using preg_match()";
}