davedpss Posted November 19, 2011 Share Posted November 19, 2011 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 More sharing options...
birbal Posted November 19, 2011 Share Posted November 19, 2011 something like $variables['taxonomy'] ["taxonomy_term_{$variables[field_journal_name][0][value]}"] ['title'] should work Link to comment Share on other sites More sharing options...
davedpss Posted November 19, 2011 Author Share Posted November 19, 2011 $taxname = $variables['taxonomy']['taxonomy_term_'.$termid]['title']; worked (someone from another forum gave this to me) which is basically a variation of what you have here. Thank you. I made it harder than it had to be. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.