How can the str_replace function be used to efficiently replace specific characters in a string in PHP?

The str_replace function in PHP can be used to efficiently replace specific characters in a string by providing the character(s) to be replaced, the character(s) to replace them with, and the input string. This function can be particularly useful when you need to replace multiple occurrences of a character or a substring within a string.

// Example of using str_replace to replace specific characters in a string
$input_string = "Hello World";
$replacement_string = str_replace("o", "0", $input_string);

echo $replacement_string; // Output: Hell0 W0rld