- vsprintf: documentation ( source)
- str_replace: documentation ( source)
<?php
function str_multiple_replace($str, $needle, $subs) {
return vsprintf(str_replace(array('%', $needle), array('%%', '%s'), $str), $subs);
}
$string = ">>>?<<<%%s>>>?<<<>>>?<<<";
echo str_multiple_replace($string, '?', array('Hello', 'World', '!'));