[Phpwm] Passing parameters to callback functions

Mike Tipping mike at etuna.co.uk
Mon May 19 10:05:38 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.





More information about the Phpwm mailing list