Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7917129
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T15:02:54+00:00 2026-06-03T15:02:54+00:00

I have some content types (nodes) that are attached to various taxonomies. For specific

  • 0

I have some content types (nodes) that are attached to various taxonomies. For specific node types, I want to do some validation on the taxonomy. I do not want to hard-code the nodes types and their corresponding fields that reference the taxonomy. So I put them in array.

However, I am unable to dereference the field names. I’ve tried double $$, quotes, etc, but can’t get it to work. Is what I want to do possible?

Below is a standalone PHP that I am trying to get to work.

<?php

$node = (object) array(
    'nid' => NULL,
    'vid' => NULL,
    'uid' => '1',
    'type' => 'price_document',
    'language' => 'und',
    'field_taxonomy_price' => array(
        'und' => array(
            array(
                'tid' => '94'
            )
        )
    ),
);


  $nodes_to_check = array("price_document" => "field_taxonomy_price",
                          "package"        => "field_taxonomy_package",
                         );



  if (array_key_exists($node->type,$nodes_to_check)) {
    $taxonomy_field = $nodes_to_check[$node->type];
    print_r($taxonomy_field);
    $tid = $node->field_taxonomy_price ['und'][0]['tid']; //  <- this works but, how
    //$tid = $node->"$$taxonomy_field" ['und'][0]['tid'];     <- can I deref variable?
  }
?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T15:02:57+00:00Added an answer on June 3, 2026 at 3:02 pm

    Well, you can do this:

     $taxonomy_field = $nodes_to_check[$node->type];
     $tid = $node->{$taxonomy_field}['und'][0]['tid];
    

    You don’t need the double dollar signs. That’s in case you want to do things like this:

     $dog = "I am a dog";
     $var = "dog";
     $$var = "Now I'm a pussycat";
     echo $dog; // Output: Now I'm a pussycat
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some content that I want to appear on multiple pages of my
Well, I have a number of different content types that I want to make
I need to develop a site on Drupal 7. I have some content types
I have some content that I am loading using jquery ajax. The content has
I have some content I want to show in iframe with fancybox. When I
I have to choose the structure of a database that will store content types
i have a .net user control to add some opinions nodes to umbraco content
I have some content that is generated by the Drupal CMS that contains strings
I have a content type that references multiple nodes, and I need a way
I have some text stored in the body field of a custom content type

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.