php - Adding foreach to a template engine -


i trying add foreach loop template working on keep getting thrown error warning: preg_replace(): parameter mismatch, pattern string while replacement array understand error saying don't know how fix it. can help?

here preg_replace's

/* foreach statement */ $content = preg_replace('/\{foreach (.*)\}/u', '<?php foreach ($1) { ?>', $content); $content = preg_replace('/\{\/foreach\}/u', '<?php }; ?>', $content); 

and here .php file created variable

$names = array(         'name',         'name2',         'name3',         'name4'     );  $template->assign('members', $names); 

and here implemented on page

<p>here members of family:</p>  {foreach ({members} $member)}     <p>$member</p> {/foreach} 

i think after {foreach ($members $member)} in template


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -