On Wed, Jul 9, 2008 at 5:21 AM, Maxim Antonov <max@xxxxxxxxxxxxxxx> wrote: > Hi, all! > > I try to use folowing regular expression: > $out = > preg_replace('#\{%%%.*?\{%bigfoto%\}.*?%%%\}#is','==REPLACEMENT==',$str); > > It not work as I need. Please tell me - what I do wrong? > > I have string: > > > <tr><td>NAME:</td><td><input type="text" name="name" value="" > size="80"/></td></tr> > <tr><td>Foto:</td><td><input type="file" name="foto" value="{%foto%}" /> > {%%%<br/><img alt="{%name%}" src="{%foto%}"/>%%%} > </td></tr> > <tr><td>Big foto:</td><td><input type="file" name="bigfoto" value="" /> > {%%%<br/><img alt="{%name%}" src="{%bigfoto%}"/>%%%} > </td></tr> > > > > I need result as: > > > <tr><td>NAME:</td><td><input type="text" name="name" value="" > size="80"/></td></tr> > <tr><td>Foto:</td><td><input type="file" name="foto" value="{%foto%}" /> > {%%%<br/><img alt="{%name%}" src="{%foto%}"/>%%%} > </td></tr> > ==REPLACEMENT== > > > And I have this result: > > <tr><td>NAME:</td><td><input type="text" name="name" value="" > size="80"/></td></tr> > <tr><td>Foto:</td><td><input type="file" name="foto" value="{%foto%}" /> > ==REPLACEMENT== > </td></tr> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > I'm sure it won't be this easy because of who knows what (like inheriting code, etc), but why not just use something easier like: $replace = array( '{%key1%}' => 'value1', '{%key2%}' => 'value2' ); $html = str_replace( array_keys($replace), array_values($replace), file_get_contents('tpl.html') ); Or the easiest is to just use raw php code seeing as php is a templating language. :) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php