What potential issues can arise when using multiple str_replace() functions in PHP for text manipulation?

When using multiple str_replace() functions in PHP for text manipulation, potential issues can arise when the replacement strings contain the same text that needs to be replaced. This can result in unintended replacements or incorrect output. To solve this issue, you can use an array in str_replace() to ensure that replacements are done in the correct order.

// Example code snippet to demonstrate using an array in str_replace() to avoid conflicts
$text = "Hello world!";
$replacements = array(
    "Hello" => "Hi",
    "Hi" => "Hey"
);

$result = $text;
foreach ($replacements as $search => $replace) {
    $result = str_replace($search, $replace, $result);
}

echo $result; // Output: Hey world!