<html>
<body>
<p>Search an array for the value "RED", and then replace it with "pink".</p>
$arr = array("blue","red","green","yellow");
print_r(str_replace("red","pink",$arr,$i));
echo "<br>" . "Replacements: $i";
</body>
<!-- Mirrored from www.w3schools.com/php/phptryit.asp?filename=tryphp_func_string_str_replace2 by HTTrack Website Copier/3.x [XR&CO'2014], Mon, 05 Sep 2022 15:02:09 GMT -->
</html>
Search an array for the value "RED", and then replace it with "pink".
Array ( [0] => blue [1] => pink [2] => green [3] => yellow )