replace all letters in a string php code example
Example 1: 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);
Example 2: replace all numbers in string php
$words = preg_replace('/[0-9]+/', '', $words);