In what scenarios is it advisable to use str_replace over eregi_replace for replacing placeholders in PHP strings?

When replacing placeholders in PHP strings, it is advisable to use str_replace over eregi_replace when the replacement does not require regular expression matching. str_replace is faster and more efficient for simple string replacements, while eregi_replace should be used when pattern matching with regular expressions is necessary.

// Using str_replace to replace placeholders in a string
$string = "Hello, [name]! Today is [day].";
$replacements = array("[name]" => "John", "[day]" => "Monday");
$newString = str_replace(array_keys($replacements), array_values($replacements), $string);
echo $newString;