Re: variable placeholders in a text file

From: Date: Sat, 05 Jan 2013 10:20:09 +0000
Subject: Re: variable placeholders in a text file
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-320036@lists.php.net to get a copy of this message
On Mon, Dec 31, 2012 at 02:29:38PM -0600, Nelson Green wrote: > > On Mon, 31 Dec 2012 19:59:02, Ashley Sheridan wrote: > _______________________________ > > > > On Mon, 2012-12-31 at 13:39 -0600, Nelson Green wrote: > <snip snip> Nelson (et al), I've enjoyed reading this thread and apologize for dredging it up. It's interesting to see your progression of thought and the templating discussion is indeed a worthy one. However, I wanted to answer this objection from your initial message: >The reason I ask is because I am going to want to do three substitutions, >and I'd rather not do three str_replace calls if I don't have to. You *don't* have to; str_replace() is perfectly capable of handling arrays: ===== $replace = array("USER","SITENAME","SOME_CONSTANT"); $replacements = array($user,$site_name,$foo); $replaced = str_replace($replace,$replacements,file_get_contents("/somefile.txt")); ===== This, of course, doesn't negate a good templating system* ... but it's handy to know and you'll probably use it sooner or later. Kevin Kinsey P.S. *assuming that's not an oxymoron!

« previous php.general (#320036) next »