The easiest way to pass more than one parameters to the callback function is with the 'use' keyword.
[This is better than using global, because it works even when we are already inside a function.]
In this example, the callback function is an anonymous function, which takes one argument, $match, supplied by preg_replace_callback(). The extra
"use ($ten)" puts the $ten variable into scope for the function.
<?php
$string = "Some numbers: one: 1; two: 2; three: 3 end";
$ten = 10;
$newstring = preg_replace_callback(
'/(\\d+)/',
function($match) use ($ten) { return (($match[0] + $ten)); },
$string
);
echo $newstring;
?>