3v4l.org

run code in 300+ PHP versions simultaneously
<?php $phrase = "You should eat fruuits, vegetaaables, and fiiibeeer every day."; $healthy = array("fruits", "vegetables", "fiber"); $patterns = array_map(function($term){ $newterm = ""; for($x=0; $x<strlen($term); $x++) $newterm.= preg_escape($term[$x], "~")."+"; return "~(".$newterm.")~"; }, $healthy); print_r($patterns); $yummy = array("pizza", "beer", "ice cream"); $newphrase = str_replace($healthy, $yummy, $phrase);

preferences:
56.16 ms | 402 KiB | 5 Q