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 d
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
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 $fo
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
T
vid Clough; php-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'
[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
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
7 matches
Mail list logo