Jump to content

Referencing Variables $$


razormedia

Recommended Posts

I haven't posted here before but I am completely stuck.

 

I've checked everywhere and cannot find answer to this question.

 

I have an array and if I were to do this:

 

echo $partNames[$jjk];

 

it would return another part of an array as such:

 

$decoded[0]["Parts"][3]["BodyPart"]

 

(if I retrieve type, this is a string).

 

Now, I need to return the actual value from particular array reference and I cannot for the life of me do it and its destroying my will to live. i've tried combinations of:

 

 

echo $partNames[$jjk];

 

echo $$partNames[$jjk];

 

echo ${$partNames[$jjk]};

 

echo ${$partNames}[$jjk];

 

$sssttt = substr($partNames[$jjk], 1);

echo $sssttt.' - '.${$sssttt};

 

Yet nothing seems to work.

Solution is to rewrite whole script but this is now pretty complicated parser and I do not want to rewrite sections as deadlines are looming.

 

Any help would be appreciated. (I'm new but i'll try to help others now in anticipation of help).

 

Cheers

Link to comment
https://forums.phpfreaks.com/topic/248766-referencing-variables/
Share on other sites

apologies salathe, let me try to clarify:

 

$partNames is an array

$jjk is just numeric (used in for loop)

$decoded is an array

 

so for example, $partnames is an array of strings which I want as references to another array; ie:

 

$partNames[0] = "$decoded[0]["Parts"][3]["BodyPart"]";

 

its how to use this string as a reference to the particular value held in

$decoded[0]["Parts"][3]["BodyPart"]

 

thats the question.

 

make sense or still confusing?

 

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.