Why does this code work for the current term but not the parent term? This code below displays the current taxonomy term on a taxonomy term page

$current = taxonomy_term_load(arg(2)); ?&gt;
if ($current): ?&gt;
echo $current-&gt;name; ?&gt;
endif; ?&gt;


The code below displays the error: "Notice: Trying to get property of non-object in eval() (line 9 of...)  Line 9 is "echo $parent->name;"

$parent = taxonomy_get_parents($current-&gt;tid);
if ($parent){
echo $parent-&gt;name;
}?&gt;


I'm really confused as to why the first set of code works but the 2nd doesn't? "print_r($parent);" displays the info below, so the data is there.

Array ( [3218] => stdClass Object ( [tid] => 3218 [vid] => 12 [name] => NAME OF TAXONOMY TERM [description] => This is the description area [format] => full_html [weight] => 0 [vocabulary_machine_name] => mfr_model [field_displayed_view] => Array ( [und] => Array ( [0] => Array ( [vname] => final_term_pages|testing [vargs] => ) ) ) [metatags] => Array ( [und] => Array ( [title] => Array ( [value] => This is the meta page title ) [description] => Array ( [value] => This is the meta description ) ) ) ) )
If you check out the docs for taxonomy_get_parents() you can see that the return value is an array of parent terms.

So you might loop through the results like this:

$parents = taxonomy_get_parents($current-&gt;tid);
foreach ($parents as $parent) {
  echo $parent-&gt;name;
}


or use just the first one like this:

$parents = taxonomy_get_parents($current-&gt;tid);
if ($parents) {
  echo $parents[0]-&gt;name;
}