Function name: mb_eregi_replace()
Function description: The mb_eregi_replace() function is a multibyte string function that performs case-insensitive regular expression replacement operations. It looks for matching parts in the string by using regular expression patterns and replaces them with the specified replacement string.
Function signature: string mb_eregi_replace ( string $pattern , string $replacement , string $string [, string $option = "msri" ] )
parameter:
Return value: The result string after performing the replacement operation.
Notes:
Example:
$string = "Hello, PHP!"; $pattern = "php"; $replacement = "World"; $result = mb_eregi_replace($pattern, $replacement, $string); echo $result; // 输出: Hello, World!
In the example above, we use the mb_eregi_replace() function to replace "php" in the string with "World". Since this function is case-insensitive, no matter whether "php" in the string is uppercase or lowercase, it will be replaced correctly. Finally, we output the result string "Hello, World!" through the echo statement.