PHP < 5.3:
preg_replace_callback('/\s*\d+\s*/', create_function('$a', 'return trim($a[0]) > 5000? " " : $a[0];'), $input);
PHP >= 5.3 (closure support):
preg_replace_callback('/\s*\d+\s*/', function ($a) {
return trim($a[0]) > 5000? " " : $a[0];
}, $input);
solved I want a function to remove numbers higher than 5000 in a string [closed]