RE: [PHP] Parsing variables within string variables

2006-04-07 Thread Kevin Davies - Bonhurst Consulting
David, Is this what you're looking for? $bar = 'Hello '.$bar HTH, Kevin -Original Message- From: David Clough [mailto:[EMAIL PROTECTED] Sent: 07 April 2006 17:37 To: php-general@lists.php.net Subject: [PHP] Parsing variables within string variables I've been bashing my head against

RE: [PHP] Parsing variables within string variables

2006-04-07 Thread Jay Blanchard
[snip] 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

RE: [PHP] Parsing variables within string variables

2006-04-07 Thread Chrome
-general@lists.php.net Subject: RE: [PHP] Parsing variables within string variables [snip] 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

Re: [PHP] Parsing variables within string variables

2006-04-07 Thread Paul Novitski
At 09:37 AM 4/7/2006, David Clough wrote: 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

Re: [PHP] Parsing variables within string variables

2006-04-07 Thread Paul Novitski
I wrote: You need to EVALUATE the string coming from the database: Assuming that $sDataField contains the string 'Hello $foo': $foo = cat; $sText = eval($sDataField); RESULT: $sText = Hello cat http://php.net/eval I was assuming that you meant that the string Hello $foo --

Re: [PHP] Parsing variables within string variables

2006-04-07 Thread Dave Goodchild
Use double quotes/ On 07/04/06, David Clough [EMAIL PROTECTED] 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

Re: [PHP] Parsing variables within string variables

2006-04-07 Thread David Clough
Dear Paul, this is exactly the problem: the string including the dollar sign comes from the database. The problem I have is that the echo statement parses the $bar reference, but not the $foo reference within it. So echo $bar generates Hello $foo which is better than $bar but