0

I need to access an array value but don't know all the values to call until I get them from a different array value. I'm not explaining this well so I will show some of the code below (This is from a drupal based website).

I want to access this value:

$variables[taxonomy][taxonomy_term_1083][title]

The problem is I don't know the term id (1083) until I have accessed this value:

$variables[field_journal_name][0][value]

I have tried creating a string that combines the term id with the rest of the array:

$termid = $variables[field_journal_name][0][value];
$taxname = 'variables[taxonomy][taxonomy_term_'.$termid.'][title]';

and then using the variable variable method:

$name = ${$taxname};

and many different variations of this but nothing seems to work.

Any ideas would be greatly appreciated.

Thanks - Dave.

2
Contributors
1
Reply
2
Views
5 Years
Discussion Span
Last Post by diafol
0

First of all, I think your array structure:

$variables[taxonomy][taxonomy_term_1083][title]

should be

$variables['taxonomy']['term']['1083']['title']

Anyway...

$taxname = 'variables[taxonomy][taxonomy_term_'.$termid.'][title]';

should be

$taxname = $variables['taxonomy']['taxonomy_term_'.$termid]['title'];
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.