How to replace multiple words from a string in PHP

1 Answer

0 votes
$s  = "PHP programming language originally designed for web development";
$words = ["PHP", "originally", "for"];
$replace   = ["java", "that", "also for"];

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

echo $s;



/*
run:

java programming language that designed also for web development
 
*/

 



answered Feb 28, 2019 by avibootz
...