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?
a strange question
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: a strange question
Use str_replace(). It will not matter where the tag to be replaces is in the template.
(#10850)
Re: a strange question
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
http://us3.php.net/manual/en/function.substr.php