I need a little help. Because preg_replace
is deprecated, I have to convert all my preg_replace
to preg_replace_callback
...
What I've tried:
Change:
$template = preg_replace ( "#\\[aviable=(.+?)\\](.*?)\\[/aviable\\]#ies", "\$this->check_module('\\1', '\\2')", $template );
To:
$template = preg_replace_callback ( "#\\[aviable=(.+?)\\](.*?)\\[/aviable\\]#isu",
return $this->check_module($this['1'], $this['2']);
$template );
Error:
Parse error: syntax error, unexpected 'return'
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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With