preg_replace_callback – Perform a regular expression search and replace using a callback
To use this function within a class do the following:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
class myClass{ function call($content){ $content = preg_replace_callback("/[b]([^[]*)[/b]/i", array($this,'callback'), $content); return $content; } function callback($match){ return "".$match[1].""; } } |