This code:
$t = 100;
$str = preg_replace_callback("/(Name[A-Z]+[0-9]*)/",
create_function(
'$matches',
'return $matches[1] + $t;'
), $func);
How to make $t visible from create_function() in preg_replace() function?
function($matchtes)use($t){/*..*/}- KingCrunch"1" + 100;) But I see, what you mean: The regular expression matches something starting withName, thus the function will always return100(=$t). Probably not wanted. - KingCrunchuseconstruct. This requires at least PHP 5.3. BTW, if the value of $t doesn't every change, you might consider using a constant which will be available in any context. - Wil Moore III