How can the function eregi be replaced with preg_match in PHP code for compatibility with PHP 5.5.0 and newer versions?

The eregi function in PHP is deprecated as of PHP 5.3.0 and removed in PHP 7. To replace eregi with preg_match for compatibility with PHP 5.5.0 and newer versions, you can use the preg_match function with the 'i' modifier to perform a case-insensitive match.

// Before
if (eregi('pattern', $string)) {
    // do something
}

// After
if (preg_match('/pattern/i', $string)) {
    // do something
}