preg_replace_callback

preg_replace_callback

(PHP 4 >= 4.0.5, PHP 5, PHP 7)

preg_replace_callbackPerform a regular expression search and replace using a callback

Description

mixed preg_replace_callback ( mixed $pattern , callable $callback , mixed $subject [, int $limit = -1 [, int &$count ]] )

The behavior of this function is almost identical to preg_replace(), except for the fact that instead of replacement parameter, one should specify a callback.