The function of the mb_eregi_replace function is to replace it with regular expressions and is case-insensitive. The function signature is as follows:
string mb_eregi_replace ( string $pattern , string $replacement , string $string [, string $option = "msr" ] )
$pattern : Regular expression pattern, note that no delimiter is required.
$replacement : The replaced string.
$string : The original string to be replaced.
$option : Optional parameter, default is "msr".
Suppose we have a piece of text that wants to replace all "example.com" or "Example.com" with "m66.net", code example:
<?php
$text = "access Example.com Get more information。";
$pattern = "example.com";
$replacement = "m66.net";
$replaced_text = mb_eregi_replace($pattern, $replacement, $text);
echo $replaced_text; // Output:access m66.net Get more information。
?>
mb_eregi_replace does not return a boolean value that succeeds in replacing it, but only returns the replaced string. Therefore, to determine whether the replacement is successful, you can use strpos() to determine whether the replaced string contains the target string.
Continuing with the above example, we want to determine whether the text already contains "m66.net":
请access http://m66.net Learn more。
Successful replacement