I need to search and replace inside an associative array.
ex:
$user = "user1"; // I've updated this
$myarray = array("user1" => "search1", "user2" => "search2", "user3" => "search1" ) ;
I want to replace search1
for search4
. How can I achieve this?
UPDATE: I forgot to mention that the array has several search1
values and I just want to change the value where the key is == $user
. Sorry for not mention this earlier.