[prev in list] [next in list] [prev in thread] [next in thread]
List: php-general
Subject: RE: [PHP] Replace or regex?
From: "Dan Joseph" <djoseph () twmi ! rr ! com>
Date: 2004-09-30 15:38:34
Message-ID: 200409301543.i8UFhEX22689 () tma1 ! cdnet ! net
[Download RAW message or body]
Hi,
> > I have a string: ##CODE## and I want to replace that with <a
> > href="somewhere.php?id=CODE">CODE</a>
I handle %code% tags in some templates I use... here's the code I have..
function show ($template, $tag) {
$file = fopen ($template, "r") or
die($error_string());
while (!feof($file)) {
$line_in = fgets($file, 1024);
$line_out .= $line_in;
}
if ($tag != 0) {
foreach ($tag as $name => $value) {
$line_out = str_replace ("%$name%",
$value, $line_out);
}
}
return $line_out;
fclose ($file);
}
Hope that helps..
-Dan Joseph
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic