Search and replace multiple values with multiple/different values in PHP5?

后端 未结 5 2229
日久生厌
日久生厌 2020-11-30 03:35

Is there an inbuilt PHP function to replace multiple values inside a string with an array that dictates exactly what is replaced with what?

For example:



        
5条回答
  •  借酒劲吻你
    2020-11-30 03:38

    $string = 'blah blarh bleh bleh blarh';
    $trans = array("blah" => "blerh", "bleh" => "blerh");
    $result = strtr($string,$trans);
    

    You can check the manual for detailed explanation.

提交回复
热议问题