$tagparser = $this->tagparser; $message = preg_replace_callback( "/\[" . $tag . "=("|\"|'|)([0-9,\s]+)\\1\](.*)\[\/" . $tag . "\]/siU", function($m) use ($parser, $tagparser) { return $tagparser->$parser($m[3], $m[2]); }, $message );