Page 1 of 1

a strange question

Posted: Thu Feb 11, 2010 11:48 am
by gotornot
Hi

I wonder if anyone can help.
I am trying to create a script that will create a form dynamically then slot it into an html template where it says {SHOWFORM} the trouble is as with a simple string replace its great for using allready output code however this will call the template find the tag then replace it with the form.
Each template will be unique so it will be in a different place each time is there any easy way or shall i just bung it in a function and try the string replace thing?

Re: a strange question

Posted: Thu Feb 11, 2010 12:33 pm
by Christopher
Use str_replace(). It will not matter where the tag to be replaces is in the template.

Re: a strange question

Posted: Thu Feb 11, 2010 12:34 pm
by JNettles
You could try Smarty, which is a pretty good templating system for PHP that can do like what you describe. If you don't want to go full-blown Smarty you can use substr to do the string replacement - in fact I have a note posted on the PHP manual substr page that does close to what you're asking for.

http://us3.php.net/manual/en/function.substr.php