var value = one || two;
var params = ['John', 10]; var str = 'Hi ?, you are ? age!'; var result = str.replace(/\?/img, function (q, w, e, r) { return params.shift(); }); alert(result);
$params = array('John', 10); $str = 'Hi ?, you are ? age!'; $result = preg_replace_callback('/\?/imu', function($q, $w, $e, $r) { global $params; return array_shift($params); }, $str); echo $result;