Jump to content

Sending multiple parameters to a callback in preg_replace or preg_replace_callba


MattLG

Recommended Posts

I have a callback to a function which is expecting two parameters:

 

function productsMenu($page, $match) {......}

 

The callback is stored in $callback which needs to be called from $page (which is an instance of a Page object). So I need to send "$this" to the callback, along with one of the matches. Something like this:

 

$content = preg_replace("/()()().../e", $callback($this, $2), $content);

 

(you get the idea...)

 

But, I've tried all kinds of syntax with various combinations of quotes, doublequotes, backslashes, ampersands. Everything that I thought should work, didn't work, and nothing that I just guessed worked either.

 

Any help or pointers you can give are very gratefully received.

 

Many thanks

 

MattLG

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.