Is there a way of referencing an array key from within the array? This may make more sense in code format:
$array=array(
"Key1"=>array(
"Value1",
"Value2"
),
"Key2"=>&$this['Key1']
);
What I want is for $array['Key2'] to output the same as $array['Key1']. I can add $array['Key2']=&$array['Key1']; after the array is created, but would like to keep it all in one code block if possible.
I've checked the docs on references, as well as some of the suggest similar questions here and a search for "php array reference".
$ref = array("Value1", "Value2");and then do$array = array('Key1'=>&$ref, 'Key2'=>&$ref);andunset($ref);afterwards - but there's no point, you'd just do the thing you suggested and create the reference afterwards.$class=array( "W"=>array( "S"=>array( /* Figure out the class */ ), "N"=>&$class['W']['S'] ) );That was the plan, anyway.