How do I run preg_replace matches through function, before replacing them?
myfunction($value = NULL) {
}
preg_replace('/(?<=\[\[)(.*?)(?=\]\])/', myfunction('$0'), 'aaa[[replace]]aaa')
The problem with the code above, is that $0 is not a variable while it’s in a function. But when it’s returned, it changes to a matched string.
You need to use preg_replace_callback to pass it through function first