class Callback
{
    public $parameter;
    public function handle($matches)
    {
        return $matches[1] . ($matches[2] + $this->parameter);
    }
}
$instance = new Callback();
$instance->parameter = 99;
echo preg_replace_callback("|(\d{2}/\d{2}/)(\d{4})|", array($instance, 'handle'), $text);
Reference
No comments:
Post a Comment