extracting words from templates

From: Date: Tue, 22 Aug 2000 16:40:48 +0000
Subject: extracting words from templates
Groups: php.general 
Request: Send a blank email to php-general+get-12974@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.

« previous php.general (#12974) next »