- array_shift: documentation ( source)
- explode: documentation ( source)
<?php
$params = ['first param ?', 'second param'];
$query = 'my string ? other string ?';
$str = '';
foreach(explode('?', $query, count($params) + 1) as $token) {
$str .= $token . array_shift($params);
}
echo $str;