AGAIN: [PHP] extracting words from templates
| From: | Jim Brown, Sr. | Date: | Tue, 22 Aug 2000 19:24:09 +0000 |
| Subject: | AGAIN: [PHP] extracting words from templates | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-13005@lists.php.net to get a copy of this message | ||
Greetings,
I've got a question:
What's the best way to extract a word from inside a template variable? If the
variable in the template is '%%TITLE%%', how could I just extract 'TITLE' from
it so I can make it '$TITLE' in my script which will print the title when I call
'print "<TITLE>$TITLE</TITLE>";'??
Here's what I'm doing now:
$header = file('includes/header.inc');
while (list(,$val) = each($header)) {
if (eregi('%%TITLE%%', "$val")) {
$title = str_replace('%%TITLE%%', "$TITLE", "$val");
echo "$title";
}
elseif (eregi('%%BGCOLOR%%', "$val")) {
$body = str_replace('%%BGCOLOR%%', "$BGCOLOR", "$val");
echo "$body";
}
else {
echo "$val";
}
}
TIA
--
James Brown, Sr.
CIO | DNS/System/Network Administrator
Sys-Admin@CSUinternet.net | CSU internet, inc. - Tifton, GA.
--
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