Hello,
I've got a question or two regarding variable variables. First off, before I ask, I want to give an example of what i'm doing - and what i'm trying to do.
# selecting all settings
$sql = "SELECT * FROM settings";
$query = mysql_query($sql);
while( $table=mysql_fetch_assoc($query) ) {
# for every result, let's loop through and set sessions
foreach( $table as $d_row ) {
foreach ( $d_row as $field=>$val ) {
$_SESSION[$field] = $val;
}
}
With me so far? with the above, everything seems to be all fine and well.
$my_name = $_SESSION['myname'];
echo "$my_name"; // prints "deadlysin3"
All is fine here too. However, what i'm looking to do is this.
Instead of implicitly saying:
$my_name = $_SESSION['myname'];
I want to use variable variables to do this in the above foreach loop. I want to say for every $_SESSION[$field] - I want the $field name to .. itself, be a variable so I don't have to define them every time.
$$field = $_SESSION[$field] ;
echo $myname; // prints nothing :(
Anyone have a tip or two on how I can get this done?