Use str_replace() with an array and a count variable in PHP
Description
The following code shows how to use str_replace() with an array and a count variable.
Example
/* ww w .j a va2s . c om*/
<?php
$arr = array("blue","red","green","yellow");
print_r(str_ireplace("RED","pink",$arr,$i)); // This function is case-insensitive
echo "Replacements: $i";
?>
The code above generates the following result.