Re: interpreting variables containing in another variable
| From: | Chris Shiflett | Date: | Wed, 20 Nov 2002 18:50:48 +0000 |
| Subject: | Re: interpreting variables containing in another variable | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-125293@lists.php.net to get a copy of this message | ||
--- ROBERT MCPEAK <RMCPEAK@jhuccp.org> wrote:
> I've got a variable - $email_body, that contain's other variables.
> For example, echo "$email_body," might look like this:
>
> $name, $address, $phone, $blah
>
> I want those variables to interpreted with corresponding values set
> earlier in the script. So, in effect, where name=bob, address=101
> east main, phone=555-5555, and blah=foo, echo "$email_body" would
> look like this:
>
> bob, 101 east main, 555-5555, foo
Check out the eval() function:
http://www.php.net/manual/en/function.eval.php
Also, you might want to consider altering your approach slightly. For
example, maybe something like this would be more appropriate:
$email_body = "$name, $address, $phone, $blah";
If you echo $email_body in this case, it will output:
bob, 101 east main, 555-5555, foo
Good luck.
Chris