str_replace() for multiple value replacement

后端 未结 6 1448
Happy的楠姐
Happy的楠姐 2020-12-03 10:30

Is there any possibility to use str_replace for multiple value replacement in a single line. For example i want to replace \' \' with \'-\'

6条回答
  •  离开以前
    2020-12-03 10:50

    $name = abcd;
    

    I want to replace 'a' with '$' and 'b' with '!', so I need to write like this:

    $str = ['a','b'];
    $rplc =['$','!'];
    
    echo str_replace("$str","$rplc",$name);
    

    output : $!cd

提交回复
热议问题