How can multiple replacements, such as replacing "Äpfel" with "Birnen" and "Eier" with "Milch", be achieved in PHP code when processing included files?

When processing included files in PHP, multiple replacements can be achieved by reading the file contents, using the str_replace() function to replace each desired string, and then writing the modified content back to the file. This can be done by opening the file for both reading and writing, performing the replacements, and then saving the changes.

$file = 'example.txt';
$content = file_get_contents($file);
$content = str_replace('Äpfel', 'Birnen', $content);
$content = str_replace('Eier', 'Milch', $content);
file_put_contents($file, $content);