Jump to content

Creating A Variable Where Part Of It Is Dynamic


davedpss

Recommended Posts

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.

Link to comment
Share on other sites

something like

$variables['taxonomy'] ["taxonomy_term_{$variables[field_journal_name][0][value]}"] ['title']

should work

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...