What is the issue with using str_ireplace in nested for loops in PHP?

Using `str_ireplace` in nested for loops in PHP can lead to unexpected results or errors because it can replace the same string multiple times within the nested loops. To solve this issue, you can create a temporary copy of the original string before entering the nested loops and then perform the replacement on the copy instead of the original string.

// Original string
$string = "Hello world, hello universe";

// Create a copy of the original string
$originalString = $string;

// Perform replacements on the copy
$replacedString = str_ireplace("hello", "hi", $originalString);

// Output the replaced string
echo $replacedString;