The
preg_replace_array
function replaces a given pattern in the string sequentially using an array: