Drupal - PHP Validation
<p>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. </p>

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

<p>Below is a standalone PHP that I am trying to get to work.</p>

<pre><code>&lt;?php

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


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



  if (array_key_exists($node-&gt;type,$nodes_to_check)) {
    $taxonomy_field = $nodes_to_check[$node-&gt;type];
    print_r($taxonomy_field);
    $tid = $node-&gt;field_taxonomy_price ['und'][0]['tid']; //  &lt;- this works but, how
    //$tid = $node-&gt;"$$taxonomy_field" ['und'][0]['tid'];     &lt;- can I deref variable?
  }
?&gt;
</code></pre>
