title: Drupal - How to get term Id from name with taxonomy_get_term_by_name
body: <p>I have tried to use the following code to get a termId from a term:</p>
  
  <pre><code>  $term = taxonomy_get_term_by_name($address_string); 
    $termId = $term[0]-&gt;tid;
  </code></pre>
  
  <p>There is 1 result, but it is appearing as term[30] - so the above code doesn't work.</p>
  
  <p>I thought I could access the term array by looking at the first element - e.g. $term[0]</p>
  
  <p>What am I doing wrong?</p>
  
  <p>Here is the result of var_dump($term):</p>
  
  <hr>
  
  <pre><code>array (size=1)
    30 =&gt; 
      object(stdClass)[270]
        public 'tid' =&gt; string '30' (length=2)
        public 'vid' =&gt; string '4' (length=1)
        public 'name' =&gt; string 'Thonglor' (length=8)
        public 'description' =&gt; string '' (length=0)
        public 'format' =&gt; string 'filtered_html' (length=13)
        public 'weight' =&gt; string '0' (length=1)
        public 'vocabulary_machine_name' =&gt; string 'areas' (length=5)
  </code></pre>
  
  <p>Many thanks,</p>
  
  <p>PW</p>