RE: [PHP] variable placeholders in a text file
| From: | Nelson Green | Date: | Tue, 01 Jan 2013 22:08:41 +0000 |
| Subject: | RE: [PHP] variable placeholders in a text file | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-319991@lists.php.net to get a copy of this message | ||
> While using the *_once works in many cases, if you're doing a mass
> mailing kind of thing, you want to use the standard include/require so
> you can re-include it as your variables change:
>
> foreach ($customers as $customer) {
> $fullname = $customer['fullname'];
> $address = $customer['address'];
> // and so on
> include("mailing.php");
> process($mailing,$customer);
> }
>
> where mailing.php defines the $mailing variable as the content that
> got included and substituted.
>
> (Back before I came up with this, I was starting off in the same place
> as the OP -- and then I just realized "wait --- PHP *IS* a templating
> system!" a voila)
For what I am trying to do here, I think what I'm doing will suffice. Like you
did, I am going through the learning process. What I've read about templating
has whetted my appetite for bigger and better things, but I should probably
finish this first. Right now I'm just trying to personalize a rather dry
page just a bit.
Thanks!