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
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.
David,
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
Paul
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php