Jackal Posted June 30, 2007 Report Share Posted June 30, 2007 Taisu mazu template engine, viss sanāk labi, bet nezinu kā labāk uztaisīt, lai var informāciju izvadīt ciklā, piemēram, ir <ul> [saraksts] <li>{aaa}</li> [/saraksts] </ul> vajadzētu, lai rakstot, piemēram, $i = 1; while($i <= 3){ $tmpl = str_replace("{aaa}", "ccc", $tmpl); $i++; } izvadītu <ul> <li>ccc</li> <li>ccc</li> <li>ccc</li> </ul> Ir kādas idejas, kā to varētu izdarīt? Link to comment Share on other sites More sharing options...
andrisp Posted June 30, 2007 Report Share Posted June 30, 2007 Izmanto preg_match, lai izgrieztu visu, kas iekš [saraksts] un [/saraksts]. Un tad ar parastu loop'u izdrukā savu sarakstu izmantojot izgriezto saturu. Link to comment Share on other sites More sharing options...
Jackal Posted June 30, 2007 Author Report Share Posted June 30, 2007 Paldies! Par tādu preg_match funkciju nemaz nezināju. Link to comment Share on other sites More sharing options...
Jackal Posted July 1, 2007 Author Report Share Posted July 1, 2007 Tagad radās viena problēma. Nesaprotu kāpēc šis skripts nestrādā $templ=@implode('',@file('aaa.html')); preg_match("/\[menu\](.*)\[\/menu\]/", $templ, $m); echo $m[1]; aaa.html <ul> [menu] <li>aaa</li> [/menu] </ul> skripts neko neizvada, bet vajadzētu izvadīt <li>aaa</li> Link to comment Share on other sites More sharing options...
v3rb0 Posted July 1, 2007 Report Share Posted July 1, 2007 . (punkts) nozīmē jebkuru simbolu, izņemot newline Link to comment Share on other sites More sharing options...
dmitriy Posted July 1, 2007 Report Share Posted July 1, 2007 var pievienot s :) <? $templ= '<ul> [menu] <li>aaa</li> [/menu] </ul> '; preg_match("|\[menu\](.*)\[/menu\]|s", $templ, $m); die(print_r($m)); ?> Link to comment Share on other sites More sharing options...
Recommended Posts