I need to search and replace inside an associative array.
ex:
$user = \"user1\"; // I\'ve updated this $myarray = array(\"user1\" => \"search1\",
Following on from Joseph's answer, using preg_replace may enable you to use the code in other situations:
function pregReplaceInArray($pattern,$replacement,$array) { foreach ($array as $key => $value) { $array[$key] = preg_replace($pattern,$replacement,$value); } return $array; }