Mark Steudel wrote:
I was wondering if you could create variable variables for objects, please
see examples below, Im having problems getting it to work.
$data['fieldname'] = foo;
// without variable variables
$res =& $db->query( "SELECT foo FROM table" );
while( $res->fetchInto( $db_data ) )
{
echo $db_data->foo; // pretend this echos bar
}
// with variable variables
$varVar = '$db_data->'.$data['fieldname']; // should be $db_data->foo
Try using double quotes, ie.
$varVar = "$db_data->".$data['fieldname'];
James
---------------------------------------------------------
http://www.ciwcertified.com - Master CIW Designer
http://www.zend.com - Zend Certified Engineer
http://www.jamesbenson.co.uk
---------------------------------------------------------
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php