Search and replace inside an associative array

后端 未结 10 1847
没有蜡笔的小新
没有蜡笔的小新 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:42

    Why not just do

    if (isset($myarray[$user])) $myarray[$user] = 'search4';
    

提交回复
热议问题