What PHP function can be used to replace specific characters in a text string?

To replace specific characters in a text string in PHP, you can use the `str_replace()` function. This function takes three parameters: the character or characters you want to replace, the character or characters you want to replace them with, and the original text string. It will then return a new string with the specified characters replaced.

// Original text string
$text = "Hello, world!";

// Replacing the comma with an exclamation mark
$new_text = str_replace(",", "!", $text);

// Output the new text string
echo $new_text;