I need to search and replace inside an associative array.
ex:
$user = \"user1\"; // I\'ve updated this $myarray = array(\"user1\" => \"search1\",
$originalArray = array( "user1" => "search1" , "user2" => "search2" ); $pattern = 'search1'; $replace = 'search4'; $replacedArray = preg_replace( '/'.$pattern.'/' , $replace , $originalArray );
Fixes the risk mentioned in comment in response to this solution