What is the issue with the eregi_replace function in PHP and why is it deprecated?

The issue with the eregi_replace function in PHP is that it is case-insensitive, which can lead to unpredictable behavior when replacing strings. To solve this issue, it is recommended to use the preg_replace function instead, which allows for more control over case sensitivity.

$string = "Hello World";
$pattern = "/hello/i";
$replacement = "Hi";
$result = preg_replace($pattern, $replacement, $string);
echo $result; // Output: Hi World