RE: Parsing variables within string variables

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



David,

Is this what you're looking for?

$bar = 'Hello '.$bar

HTH,

Kevin


-----Original Message-----
From: David Clough [mailto:David.Clough@xxxxxxxxxxxx] 
Sent: 07 April 2006 17:37
To: php-general@xxxxxxxxxxxxx
Subject:  Parsing variables within string variables

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux