What is the difference between eregi and preg_match in PHP?

The main difference between eregi and preg_match in PHP is that eregi is a case-insensitive version of the preg_match function. This means that eregi will match patterns regardless of the case of the letters, while preg_match is case-sensitive by default. If you need to perform a case-insensitive pattern match, you should use eregi. However, it is important to note that eregi is deprecated in PHP 5.3.0 and removed in PHP 7.0.0, so it is recommended to use preg_match with the 'i' modifier instead.

// Using preg_match with the 'i' modifier for case-insensitive pattern matching
$string = "Hello World";
$pattern = "/hello/i";

if (preg_match($pattern, $string)) {
    echo "Match found!";
} else {
    echo "No match found.";
}