Variable variables

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

 



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
 
    $res =& $db->query( "SELECT foo FROM table" );
 
       while( $res->fetchInto( $db_data ) )
    {
        echo ${$varVar}; // would like this to echo bar
    }
 
 
Thanks, Mark

[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