Re: variable placeholders in a text file

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux