[Phpwm] Passing parameters to callback functions

Phil Beynon phil at infolinkelectronics.co.uk
Mon May 19 10:39:46 BST 2008


> I'm using preg_replace_callback() to replace content in a CMS system but
> need to pass some extra parameters to the call back function in addition 
> to
> the matches array that is passed by default:
>
> $fileContent = preg_replace_callback('/{cms id="([\d]*)"}/'
> ,array($this,'replaceContent'), $fileContent);
>
> So replaceContent is defined as
>
> Function replaceContent($matches, $year, $month)
>
> Does anyone know if I can pass the $year, $month and how to do it. I know 
> I
> can assign it to a class or session variable but this seems messy.
>
>

What are you trying to do here exactly - it, and I could have got the wrong 
end of the stick, sounds like a global search and replace type of function 
based on a date.

Phil




More information about the Phpwm mailing list