replace multiple occurence of character php code example
Example 1: php replace every occurrence of character in string
//replaces every occurence of $search with $replace in the string $subject
str_replace ($search, $replace, $subject);
Example 2: replace multiple characters one string php
// Provides: You should eat pizza, beer, and ice cream every day
$phrase = "You should eat fruits, vegetables, and fiber every day.";
$healthy = ["fruits", "vegetables", "fiber"];
$yummy = ["pizza", "beer", "ice cream"];
$newPhrase = str_replace($healthy, $yummy, $phrase);