Re: Parsing variables within string variables
| From: | Dave Goodchild | Date: | Fri, 07 Apr 2006 18:12:31 +0000 |
| Subject: | Re: Parsing variables within string variables | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-233459@lists.php.net to get a copy of this message | ||
Use double quotes/
On 07/04/06, David Clough <David.Clough@durham.ac.uk> wrote:
>
> I've been bashing my head against the wall on this, and would be glad of
> help to stop.
>
> I have a variable containing a string that contains the names of
> variables, and want to output the variable with the variables it
> contains evaluated. E.g.
>
> $foo contains 'cat'
> $bar contains 'Hello $foo'
>
> and I want to output $bar as
>
> Hello cat
>
> The problem is that if I use
>
> echo $bar
>
> I just get
>
> Hello $foo
>
> Note that $bar is loaded from a database query, so I can't control its
> contents: I just have to parse it.
>
> Any help appreciated.
>
> David.
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
http://www.web-buddha.co.uk
dynamic web programming from Reigate, Surrey UK
look out for e-karma, our new venture, coming soon!