Re: ereg - template HTML
| From: | Ovidiu EFTIMIE | Date: | Fri, 20 Oct 2000 14:31:30 +0000 |
| Subject: | Re: ereg - template HTML | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-21381@lists.php.net to get a copy of this message | ||
Hi Jim,
You should use Richard Hayes's temlate class
(http://www.heyes-computing.net/scripts/) or FastTemplates .
Ovidiu
-----Mesaj original-----
De la: php-general-return-21371-eovidiu=rds.ro@lists.php.net
[mailto:php-general-return-21371-eovidiu=rds.ro@lists.php.net]În numele
Jim Carey
Trimis: Friday, October 20, 2000 3:06 PM
Catre: php-general@lists.php.net
Subiect: [PHP] ereg - template HTML
Hi,
I have an array eg
$a[test] = "value1";
$a[test1] = "value2"; etc
I would like to be able to take the names in the array and find where those
names are used in an html file and then substitute the value (ie value1 and
value2) into the element identified with {{ }} around it - a std template
type of approach.
<input type=text name=test value='{{test}}'>
<input type=text name=test1 value='{{test1}}'> etc
becomes:
<input type=text name=test value='value1'>
<input type=text name=test1 value='value2'>
in Perl I could do it something like (where $HTML is the array and template
points to the template I want to fill in):
open (FILE, "<$template") or die "Couldn't open $template: $!\n";
while (<FILE>)
{
s/{{(.*?)}}/$HTML->{$1}/g;
$content .= $_;
}
close FILE;
return $content;
I guess what I am looking for is the appropriate ereg(?) statement to
achieve the above - hope someone can help ?
cheers
Jim Carey
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
For additional commands, e-mail: php-general-help@lists.php.net
To contact the list administrators, e-mail: php-list-admin@lists.php.net