What are the potential pitfalls of using the eregi function in PHP scripts?

Using the eregi function in PHP scripts can lead to potential security vulnerabilities as it is case-insensitive and can be exploited by attackers. It is recommended to use the preg_match function with the "i" modifier instead, which provides the same functionality in a more secure manner.

// Original code using eregi
if (eregi("pattern", $string)) {
    // do something
}

// Updated code using preg_match with "i" modifier
if (preg_match("/pattern/i", $string)) {
    // do something
}