Good afternoon, I am writing a template engine for my cms and faced with this question, there is code for processing functions in the template:
if (strpos($string, "{func:") !== false) { $string = preg_replace("'{func:(.+?)}(.+?){/func}'ies", "@\\1('\\2');", $string); }
But this code processes only functions with one parameter, for example: {func: date} H: i: s {/ func}, but what if the function has not one but several parameters? For example, I write {func: date} H: i: s, {time} {/ func} This piece of code should convert time from time () to a readable form, but unfortunately only one parameter is substituted into the function and something like 14 is obtained : 49: 03,1364229666. Please help me figure it out, you need to correct the code so that it processes several parameters of the function!
I wrote this for paired parameters:
if (strpos($string, "{funcpaire:") !== false) { $string = preg_replace("'{funcpaire:(.+?)}(.+?),(.+?){/funcpaire}'ies", "@\\1('\\2','\\3');", $string); }
But this is not an option, because there may be more parameters!