What is the syntax for using str_replace() with arrays in PHP?

When using str_replace() with arrays in PHP, you need to provide the function with an array of search strings and an array of replacement strings. The function will then replace each occurrence of the search strings with the corresponding replacement strings in the input array. This can be useful when you want to replace multiple different strings in one go.

$input_array = array("apple", "banana", "cherry");
$search_array = array("apple", "banana", "cherry");
$replace_array = array("orange", "grape", "strawberry");

$output_array = str_replace($search_array, $replace_array, $input_array);

print_r($output_array);