Search and replace inside an associative array

后端 未结 10 1854
没有蜡笔的小新
没有蜡笔的小新 2021-01-20 22:14

I need to search and replace inside an associative array.

ex:

$user = \"user1\"; // I\'ve updated this

$myarray = array(\"user1\" => \"search1\",         


        
10条回答
  •  醉话见心
    2021-01-20 22:53

    Using str_replace should work:

    $myarray = array("user1" => "search1", "user2" => "search2" ) ;
    
    $newArray = str_replace('search1', 'search4', $myarray);
    

提交回复
热议问题