| Posted by Janwillem Borleffs on 01/15/06 15:13 
lwoods wrote:> I want to echo the value of key 'a' by indirectly referencing it via
 > the variable $y.  The above is NOT correct, I know.
 >
 > How do I indirectly reference a variable in PHP?
 >
 
 The technique is called 'Variable variables' and looks like this:
 
 $x=array('a'=>'ant','b'=>'boat');
 $s='a';
 $y='s'; // Removed the dollar sign
 echo $x[$$y];
 
 
 JW
 [Back to original message] |