Jump to content

Variables within variables - Quick Question


Recommended Posts

Hi, just a quick question, what i am trying to do is basically this:

 

<td class="cell" align="center" height="19">'.$row["$_SESSION['name']"].'</td>

 

I.e. Placing the session variable within the row variable to obtain the result, however i as yet cannot get it to work, i assume its some clever combination of quotes and single quotes to achieve the correct syntax but i have yet to find it.

 

Help would be much appreciated.

I thought you were talking about a variable variable.

 

Ex:

 

$bar = "Hello";
$foo = "bar";

echo($$foo); // will display Hello

 

What you are dealing with is simple array keys, and yes that is one way to do it as Ken2k7 stated.

 

if you are using echo() to list the entire td element you can also do it this way:

 


echo('<td class="cell" align="center" height="19">'.$row[$_SESSION['name']].'</td>');

 

same difference.

 

if you are using echo() to list the entire td element you can also do it this way:

 


echo('<td class="cell" align="center" height="19">'.$row[$_SESSION['name']].'</td>');

 

same difference.

 

Not really. The method you posted, since concatenation is being used, will be faster/more efficient by microseconds. :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.