How to replace two words from a string in PHP

1 Answer

0 votes
$s  = "PHP java and c programmming";
$words = ["PHP", "java"];
$replace   = ["Python", "c++"];

$s = str_replace($words, $replace, $s);

echo $s;



/*
run:

Python c++ and c programmming
 
*/

 



answered Feb 28, 2019 by avibootz
...