"deprecated: preg_replace(): the /e modifier is deprecated, use preg_replace_callback instead in" Code Answer

1

the callback needs to be a function taking one parameter which is an array of matches. you can pass any kind of callback, including an anonymous function.

$template = preg_replace_callback(
    "#\[aviable=(.+?)\](.*?)\[/aviable\]#isu",
    function($matches) {
        return $this->check_module($matches[1], $matches[2]);
    },
    $template
);

(php >= 5.4.0 required in order to use $this inside the anonymous function)

By yonan2236 on October 12 2022

Answers related to “deprecated: preg_replace(): the /e modifier is deprecated, use preg_replace_callback instead in”

Only authorized users can answer the Search term. Please sign in first, or register a free account.