How can you ensure that str_replace in PHP is not case-sensitive when replacing words in a string?

When using the str_replace function in PHP to replace words in a string, it is case-sensitive by default. To make it case-insensitive, you can use the str_ireplace function instead. This function works in the same way as str_replace but ignores the case of the words being replaced.

<?php
$string = "Hello World";
$replacement = "world";
$new_string = str_ireplace("world", "PHP", $string);
echo $new_string; // Output: Hello PHP
?>