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
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?

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.