Replace multiple words with Str_Replace

后端 未结 5 2203
醉梦人生
醉梦人生 2021-01-05 18:50

I want to replace multiple synonyms with one specific word.



        
5条回答
  •  走了就别回头了
    2021-01-05 19:29

    $a = array( 'truck', 'vehicle', 'sedan', 'coupe' );
    $str = 'Honda is a truck. Toyota is a vehicle. Nissan is a sedan. Scion is a coupe.';
    echo str_replace($a,'car',str_replace('Toyota','Lexus',$str));
    

提交回复
热议问题